
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");
});
}
}