Announcements
I am currently customizing the OOB "Lead to Opportunity Sales Process" BPF. I have a requirement on the qualify stage to filter "Existing Contact?" by "Existing Account?" in a way that is identical to the filter options available on lookups on the main form. To achieve this I have written the function below and linked it to the OnChange event of ParentAccountId. The trouble with this implementation is it works too well. We want users to be able to turn off this filter if a contact needs to be added that is not associated with the specified account.
On the main form you lookup field you can specify the "users can turn off filter" option which allows them to toggle a "Filter by related company" option in the "Look up record" modal.
Unfortunately, in the function I have shown below, users are not given the option to disable the filter. Is there a way I can enable this? I would like the option to show up with the same text in the same place, if the solution ends up being non-standard or hacky it will result in them simply not using it and lots of complaints.
Any help is appreciated.
function Filter_Contact(executionContext) { var formContext = executionContext.getFormContext(); if (formContext.getControl("header_process_parentcontactid") != null) { formContext.getControl("header_process_parentcontactid").addPreSearch(function(executionContext) { var formContext = executionContext.getFormContext(); var accountId = null; var filterBpf; if ((formContext.getControl("header_process_parentaccountid") != null) && (formContext.getControl("header_process_parentaccountid").getAttribute().getValue() != null)) { accountId = formContext.getControl("header_process_parentaccountid").getAttribute().getValue()[0].id; if (accountId != null || accountId != undefined) { filterBpf = ""; formContext.getControl("header_process_parentcontactid").addCustomFilter(filterBpf); } } else { console.log("Unable to find parentaccountid"); } }); } else { console.log("Unable to find parentcontactid"); } }
Hi DorienM,
This setting can not work for the field on the BPF.
So as a workaround, you could add a two option field like "filter contacts". Then you can filter contacts or not base on its value.
André Arnaud de Cal... 291,359 Super User 2024 Season 2
Martin Dráb 230,370 Most Valuable Professional
nmaenpaa 101,156