Filtering Business Process Flow Lookup field

| Anas Arshad

When designing business process flows in Dynamics 365, one phase may have a data step that represents the search for another step in the next phase. In such cases, it would be ideal to filter the search options to show only relevant records.

This is not available OOB but can be done using JavaScript as an unsupported customization.

For example, BPF when selecting an account lookup and then filtering the contact lookup for only records related to the selected account. 

var lookupField = Xrm.Page.getControl("fieldname");

var lookupFilter = "<filter type='and'><condition attribute='category' operator='eq' value='value'></filter>";

lookupField.addCustomFilter(lookupFilter);

In the above code, replace "fieldname" with the logical name of the lookup field you want to filter, "category" with the name of the attribute you want to filter by, and "value" with the value you want to filter on.

You can add multiple conditions to the filter by appending additional <condition> elements within the <filter> element. For example:

var lookupFilter = "<filter type='and'><condition attribute='category' operator='eq' value='value1'/><condition attribute='status' operator='eq' value='value2'/></filter>";

This will filter the lookup to only show records where the "category" attribute is equal to "value1" and the "status" attribute is equal to "value2".

Note that this code should be added to the form's OnLoad event, or to a function that is called after the form has loaded.

Join us next time, as we continue our journey of learning canvas apps.Click here to learn more about Imperium's Power Apps Services. We hope this information was useful, and we look forward to sharing more insights into the Power Platform world.


M
Chief Architect, Founder, and CEO - a Microsoft recognized Power Platform solution architect.

About The Blog

Stay updated with what is happening in the Microsoft Business Applications world and initiatives Imperium is taking to ease digital transformation for customers.


More About Us

We provide guidance and strategic oversight to C-Suite and IT Directors for on-going implementations. Feel free to give us a call.

1 331 250 27 17
Send A Message

Ready to Start?

Get a personalized consultation for your project.

Book a Meeting