Working with Dynamics 365 entity records in Canvas PowerApps
When creating a Canvas PowerApp connected to Dynamics 365/CDS, you may want to present the values in an entity as options within a drop down box (combo box) or a list box for selection. This would be useful if you wanted to present select-able data in a more user-friendly manner than the standard out of the box lookup functionality. A typical scenario might be selecting a lookup value to associate to a record e.g. Expense Type lookup on an expense entity. I’ll show how we can present the Expense Types below in both a combo box and list box.
The steps are as follows:
- Connect to the CDS Entity that has the values you want to populate the control(s) with.
2. Create a Collection with that data source.
3. Add a Combo Box or List Box control and update the ‘Items’ property to the collection created in step 2
4. For a Combo Box, update the DisplayFields and SearchFields property to the schema name of the field you want displayed
5. For a List Box, update the ‘Value’ property to the schema name of the field you want to display.
6. Thats it! The screenshots below the 2 controls on a CanvasApp with the values populated with the records from the Expense Type entity from Dynamics
Hopefully this gives you a quick reference and starting point on how to work with and manipulate controls with entity records. There are further optimizations that could be made when dealing with collections of entity records e.g. only creating a collection with the columns that you actually need. This isnt covered here but it is considered best practice and should be done before anything goes into production 🙂