cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Regular Visitor

Filtering choices for linked entities in editform

When you create an edit form for an entity like opportunity, Power Apps populates various drop down menu's for related entities with the choices() function. For example:

 

Choices([@Opportunities].parentaccountid)

Choices([@Opportunities].parentcontactid)

 

I want to filter these choices, but I'm unable to figure out the correct syntax to apply a filter() function here.

Specifically I want to filter the accounts to show only active ones.

And filter the contacts to only show the ones linked to the account chosen.

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Super User II
Super User II

Re: Filtering choices for linked entities in editform

Hi @flowadmin3,

I think the expression would be something link, where the OpportunityGallery is the control that lists the opportunities.

Filter(Choices([@Opportunities].parentaccountid), statecode = 0) //accounts
Filter(Choices([@Opportunities].parentcontactid), parentaccountid = OpportunityGallery.Selected.parentaccountid) //contacts

//if you're using the feild labels instead of field names
Filter(Choices([@Opportunities].'Primary Account'), 'Status' = 0) //accounts
Filter(Choices([@Opportunities].'Primary Contact'), 'Company Name' = OpportunityGallery.Selected.'Primary Account') //contacts

 Hope this helps..

View solution in original post

3 REPLIES 3
Highlighted
Advocate V
Advocate V

Re: Filtering choices for linked entities in editform

Hello @flowadmin3,

I hope you're well. I'm not sure if this is what you're looking for, but I'll give it a try...

I added a new screen and used 2 dropdown input fields.

I connected the dropdown fields to my CDS data, the entity I'm using is called "Budget Items".

Dropdown 1 is showing all Budget Item records in the CDS. I didn't make and changes to that field.

Dropdown 2 is showing only Inactive Budget Item records. It's filtering on the Inactive Budget Items View.

I was able to show the Inactive Budget Items View by using the below:

In the "Items" property I typed the below: 

Filter('Budget Items', 'Budget Items (Views)'.'Inactive Budget Items')
This now only displays my inactive Budget Item records. See screenshot and you can see the different number of records between the two dropdown fields.

Dropdowns.png

 

I hope this helps.

Garry

Highlighted
Super User II
Super User II

Re: Filtering choices for linked entities in editform

Hi @flowadmin3,

I think the expression would be something link, where the OpportunityGallery is the control that lists the opportunities.

Filter(Choices([@Opportunities].parentaccountid), statecode = 0) //accounts
Filter(Choices([@Opportunities].parentcontactid), parentaccountid = OpportunityGallery.Selected.parentaccountid) //contacts

//if you're using the feild labels instead of field names
Filter(Choices([@Opportunities].'Primary Account'), 'Status' = 0) //accounts
Filter(Choices([@Opportunities].'Primary Contact'), 'Company Name' = OpportunityGallery.Selected.'Primary Account') //contacts

 Hope this helps..

View solution in original post

Highlighted
Regular Visitor

Re: Filtering choices for linked entities in editform

Thanks for the responses.

 

For those who run into similar issues. Filtering active Accounts was easy after all:

Filter(Choices([@Opportunities].Account), statecode='Status (Accounts)'.Active)

 

I was still unable to figure out a filter for Contacts based on the selected Account. But as it turns out, this shouldn't be done with a filter at all. Just setting the Items property to the name of the relation between Account and Contacts was enough:

AccountDataCardValue.Selected.'Contacts (contact_customer_accounts)'

 

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

Power Platform ISV Studio

Power Platform ISV Studio

ISV Studio is designed to become the go-to Power Platform destination for ISV’s to monitor & manage published applications.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Tech Marathon

Maratón de Soluciones de Negocio Microsoft

Una semana de contenido con +100 sesiones educativas, consultorios, +10 workshops Premium, Hackaton, EXPO, Networking Hall y mucho más!

Users online (7,605)