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

Community site session details

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

Filter on Business Process Flow Step

(0) ShareShare
ReportReport
Posted on by
Hello, 
 
I have the following JS web resource script where I am attempting to add a filter to the Account lookup field on the first stage of my business process flow on the Lead form, but it does not seem to work when testing it out on the form. In my console I can see the PreSearch event handler is being added but the filtering isn't being applied so I assume something is going on with the addPreSearch function. Any help is appreciated, thank you.
 
function filterAccountLookup(executionContext) {
    var formContext = executionContext.getFormContext(); 

    // Get the Lookup control for the lead's account field 
    var accountLookup = formContext.getControl("parentaccountid");
    console.log('accountLookup: ', accountLookup);

    if (accountLookup) {
        // Add PreSearch event handler for the lookup field
        console.log('Adding PreSearch event handler');

        accountLookup.addPreSearch(function () {
            // Define filter condition
            console.log('Filter defined');
            var filter = "<filter type='and'>" +
                            "<condition attribute='crdc5_type' operator='neq' value='236000002' />" +
                        "</filter>";

        // Apply the filter to the lookup field
        console.log('Applying custom filter to lookup control');
        accountLookup.addCustomFilter(filter, "account");
        });
    }
}
 
I have the same question (0)

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…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

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

#1
Sahan Hasitha Profile Picture

Sahan Hasitha 226

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 81 Super User 2025 Season 2

#3
BillurSamdancioglu Profile Picture

BillurSamdancioglu 68 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans