Working with Microsoft Dynamics 365 Customer Engagement (CE)/Dataverse option sets, or choices, in Canvas Apps can be challenging. These choices are crucial for data consistency and user interface efficiency but often present hurdles in terms of integration and functionality within apps. One major cause behind this is that the options within an option-set are stored as integer values in the database. To address these challenges and optimize your app’s performance, leveraging Microsoft Dynamics CRM Services can be highly beneficial.
This blog delves into the specific challenges faced when handling option sets in Canvas Apps, with a focus on filtering a Contact gallery based on the gender of the contact. We will explore both static and dynamic filtering methods, providing practical solutions to streamline your app development process and enhance user experience.
STEPS for Filtering Dynamics 365 CE in Canvas Apps with Option-Sets
- To begin with, we just check the available option in the Gender (Contact table) option-set:
S.No. | Option (Label) | Integer Value |
1 | Male | 1 |
2 | Female | 2 |
2. We then navigate to our Canvas-App and get an app ready with a screen, a vertical gallery with its data source being set to Dataverse’s Contact table.
3. Static Filtering: In the ITEMS property of the Gallery, we can see that if we begin to write the following formula, it displays the available options in the option-set. In our case, two: Male and Female.
Suppose we wish to see only the Female contacts. We add the following PowerFX formula to achieve the same.
ITEMS = Filter(Contacts, Gender = ‘Gender (Contacts)’.Female) |
We can see the Gallery is filtered to show Female contacts. Similarly, we can do it for the Male ones.
4. Dynamic Filtering: We now place a Combo-Box control on our Canvas-App screen and make it display the available Gender options in the drop-down, using the simple Power-FX formula:
ITEMS = Choices(‘Gender (Contacts)’) |
At this point, our desire is to filter the contacts in the gallery based on the item(s) selected in the Combo-Box. Hence, we update the Items property of our Contact Gallery as follows.
ITEMS = Filter(Contacts, Gender in <combo-box name>.SelectedItems) |
Let us test it by selecting MALE option in the combo-box.
And it certainly works for the FEMALE option, and the combination of both options too!
CONCLUSION
That is how one can develop filtering mechanisms for the choices (option-sets) in the Canvas-Apps. Effectively managing Dynamics 365 CE option sets in Canvas Apps is essential for optimal app performance and user experience. By implementing both static and dynamic filtering methods, one can overcome integration challenges and ensure seamless and efficient functionality across various app scenarios.