Skip to main content

Notifications

Announcements

No record found.

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?

  • 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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Verified Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,419 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,492 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans