Using these methods we can now easily filter the lookup in Dynamics 365.
Using addPreSearch we can specify a handler to PreSearch Event. Inside the handler we can specify our fetch xml query that can be used for filtering. The filter applied in the fetch xml will be combined with the any previously added filter as an ‘AND’ condition.
To remove the filter we can use removePreSearch method.
formContext.getControl(arg).addPreSearch(myFunction)
- Pass execution context
- Specify the argument which is nothing but the lookup field you want to addPresearch functionality.
Example:
formContext.getControl(“csz_consumedproduct”).addPreSearch(filterConsumedProductLookup);
function filterConsumedProductLookup(executionContext) {
debugger;
var entityLogicalName = “product”;
var filter = ” <filter>” +
” <condition attribute=’name’ operator=’not-like’ value=’%Accompanied%’ />” +
” </filter>”;
executionContext.getFormContext().getControl(“csz_consumedproduct”).addCustomFilter(filter, entityLogicalName)
}
Cheers,
PMDY
Cheers,
PMDY