This blog is PART 2 of the blog Series Create a Canvas App from Scratch. In this blog post we will learn how to create our first Canvas App using Common Data Service (CDS).
Introduction to Common Data Service (CDS)
Common Data Service helps to store data securely and manage it to be used for the business applications. In CDS data is stored within a set of entities which is a set of records. Common Data Service includes a set of standard entities. However, it is also possible to make custom entities as per your business needs and populate them with data using Power Query.
Let’s go through the step by step process to create a canvas app to manage employee details by using Common Data Service through a custom entity within a Solution.
- Login to Power Apps account by signing in with your credentials. If you are not aware which license you posses or how to start using Power Platform click here.
- On the Power Apps screen click on Solutions at the bottom of the left navigation bar. A pop window with form will open. Fill in the details like Display name, Name, Publisher and click on Create.
- Once the Solution is created, click on New from the top navigation bar and select App -> Canvas app -> Phone from factor.
- It will reroute to another tab to create an app with navigation menu at the top: File, Home, Insert, View, Action
- Click on File and go to settings to save an app in the solution, name it as Employee Management App and click on Save on the left navigation bar.
Steps to create a custom Entity
There are two ways to populate entity with data using power query, we will take a look at both the ways further in this blog.
- After the app is created, again click on New from the top navigation bar and this time select Entity.
- A pop-up form will appear to fill the details about New entity. Enter Display name as Employee Details, as you enter the display name it will itself take Plural display name and Name as your Display name. Click on Done and then Save the entity.
- Add Field from top navigation bar (+Add field), a pop form will open enter the details like in Display name fill Employee First Name, enter Data type as Text, Click on Done and finally Save Entity. Similarly create other fields like Employee Last Name, Employee Email Address, Employee Phone no., Employee ID, Date of Birth, Date of Joining, Salary etc. with the required data type.
- In the custom entity Employee Details, click on Data from top and select Get data.
- A new pop-up window will open with different data sources as Common data service allows data to be integrated from multiple sources to be used in Power Platform to create an app. Select Excel to use it as a data source.
- A new window will open with connection settings. Browse the file from OneDrive, for the purpose we have Employee details formatted Excel file with records saved in the OneDrive.
- Choose the file and click on Next
- It will open your file to show the records, On the left-hand side select your table and click on Transform data.
- Click on Next. FromPower Query we can make further changes, if required.
- The two ways to populate data within entity includes to load and save data either into the new entity or into an existing entity. Click on Load to existing and select the above created entity Employee details from the dropdown and map the column with the fields.
- If you select Load to new entity, a new entity will itself be created with as per the records in the Excel table mapping the source column with existing field as given below.
- Select on Refresh manually and click on Create.
- On selecting load to new entity a custom entity will be created with fields like city, country, Date of Birth, Date of Joining, Email, Emp ID, First Name, Last Name, Gender, Phone no, Salary and one Name field as Primary field.
- Data within all the fields will be saved as the records in the Excel table.
- From the left navigation bar inside the Solutions, click on the Edit to start making an app by selecting three dots, the ellipsis (…) from the custom entity as the data source.
- From the top navigation menu on the Home tab click New screen.
- A dropdown will appear and it will display all screen types, choose List.
- A newscreen is added with several default controls like Gallery control, search box, label. The gallery covers the entire screen under the search box.
- Under Tree view from left navigation bar select the BrowseGallery and for the data sources select EmployeeDetails Entity from Common Data Service, created in the above steps.
- On the right-hand side from the Properties tab, select Layout and choose Title, Subtitle and body from the different option that appear.
- Select Gallery and from the right hand under Properties, select Edit Fields and add First name in Title, Last name in Subtitle and Employee ID in Body. Also add Label of First Name, Last Name and Employee from the Insert tab on the top navigation bar selecting label and customise it from the Properties tab.
- Change the text in lbl from [Title] to Employee Details.
- In the BrowseGallery2, on the top dropdown input box, select Items and in the formula bar, replace CustomGallerySample with EmployeeDetails and replace sampleText with First Name, last name, Employee ID in first instance and with First Name in second instance.
- After this you can follow the steps given in PART 1 of this Blog Series to make a complete App using Power Apps.
It is very easy to Create a Canvas App using Common Data Service entities following the above steps that gives the flexibility to get data from more than 100 connectors as a data source. I hope this blog will help you to use Power Apps to create an app, in case of any query leave comments below.