web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics 365 | Integration, Dataverse...
Unanswered

Filtering lookups on BPF (Business Process Flow)

(0) ShareShare
ReportReport
Posted on by 125

I have seen various threads on getting a lookup to filter in the BPF.  Using the example from here:
( ) How to Filter Lookups in a Dynamics 365 Business Process Flow - Microsoft Dynamics CRM Community

I actually want to do exactly the same thing but am confused.  This is to filter the contact lookup on the BPF based on the account selected.

These fields are primarycontactid and customerid.

This is what I am trying to use, does this look correct?

function filterBpfLookup = function(formContext) {
    if (formContext.getControl("header_process_primarycontactid") !=null) {
    formContext.getControl("header_process_primarycontactid").addPreSearch(filterDefinition);
    }
    
    
    function filterDefinition = function(formContext) {
    var accountId = null;
    var accountLookup;
    var filterBpf;
    
    if (formContext.getControl("header_process_primarycontactid") != null &&
    formContext.getControl("header_process_primarycontactid").getAttribute().getValue() != null)
    
    {
    accountLookup = formContext.getControl("header_process_customerid").getAttribute().getValue();
    accountId = accountLookup[0].id;
    
    if (accountID != null || accountID != undefined) {
    filterBpf = ""  
    ""   "";
    
    formContext.getControl("header_process_primarycontactid").addCustomFilter(filterBpf);
    }}}}

Please note that I cannot write JScript to save my life.

Also if correct, do I add this to the onLoad of the form or somewhere else?

I have the same question (1)
  • A.Serie Profile Picture
    61 on at

    I also cannot write JScript, so kudos to you for taking a stab at this! I have been craving this functionality for a while. My workaround has been to just place the lookup field I want to filter directly on the form itself, that allows me to filter it how I need. I do have some scenarios where I don't need a user to complete that field until they reach a certain point of the business process flow, so I'll create a business rule to Show/Hide or Require/Unrequire the lookup field at the appropriate times. It's worked well for us so far.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Microsoft Dynamics 365 | Integration, Dataverse, and general topics

#1
Siv Sagar Profile Picture

Siv Sagar 93 Super User 2025 Season 2

#2
#ManoVerse Profile Picture

#ManoVerse 80

#3
Martin Dráb Profile Picture

Martin Dráb 64 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans