Most useful scenarios is to create what we commonly call as “Dependent OptionSets” in Dynamics 365 context.
Here, Country and State are 2 entities in CDS. Each Country has N states i.e. Country is a parent entity of State entity.
We’ll create 2 Drop-downs in a Canvas Power App i.e. 2 OptionSets namely Country and State that selection of Country will affect what should be populated in State entity. Simple!
Setting up your Drop-down controls
Let’s see how the drop-downs are set.
- Drop-down 1 is populated from Countries entity in CDS (Common Data Service)
- For State to be filtered based on the Country, we’ll use Filter() function to show records based on what Country is selected in Drop-down 1.
For Items of the Dropdown2 control, we’ll write the below formula
So, the Filter([EntityToPopulate], ‘[LookupFieldNameOfParent]’.[EntityOfParent]) = [DropdownControl].Selected.[GUIDFieldOfParentEntity])
Sorry, it’s a little rough on the eyes!
- And it will give you the below. Select Country first
select your parent record
Then, the drop down will populate child records based on the Country. So the States will show up which have lookup to India as Country.
And that was it!
Here are some more Canvas PowerApp posts you might want to look at –
- Restore older version of a Canvas Power App | Power Platform
- Implement character length validation in a Canvas Power App | Power Platform
- Logged In User details in a Canvas Power App
- Implementing Exit app, Logout and Confirm Exit features in a Canvas Power App
- Variables in Canvas Power Apps | Global and Context
- Get N:N records in a Canvas Power App using Common Data Service connector | Power Platform
- Adding a Canvas PowerApp to Teams
- Sending Image from Canvas PowerApps to SharePoint Document Library using Flows
Hope this helps!!
2 thoughts on “Dependent OptionSets in a Canvas Power App for 1:N related CDS entities | Power Platform”
This is the best article that is there on the internet for this !!!
Thanks a lot, Karan!! I’m happy this is helpful.