Skip to main content

Notifications

Announcements

No record found.

Dynamics 365 general forum
Unanswered

Filtering lookups on BPF (Business Process Flow)

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?

  • A.Serie Profile Picture
    A.Serie 61 on at
    RE: Filtering lookups on BPF (Business Process Flow)

    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

Anton Venter – Community Spotlight

Kudos to our October Community Star of the month!

Announcing Our 2024 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Dynamics 365 Community Newsletter - September 2024

Check out the latest community news

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 290,554 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 228,588 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans