I have a dropdown in a model driven app, and I want to add custom filter to it in presearch based on business logic.
In my javascript code, the presearch callback has async await because it's using
Xrm.WebApi.retrieveRecord to retrieve a record. But the custom filter is doing nothing when await is used in callback, it's only working if a remove the await in the callback .and hardcode the values that were otherwise being retrieved using await Xrm.WebApi.retrieveRecord
addPresearchToPayer = async function(executionContext) {
var formContext = executionContext.getFormContext();
var control = formContext.getControl("jg_fkpayer");
await control.addPreSearch(addPresearchToPayerCallback);
}
Callback
addPresearchToPayerCallback = async function (executionContext) {
var filter = await .....;
var control = executionContext.getEventSource();
control.addCustomFilter(filter);
}