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
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);
}
Thank you , i will be needing this on every form, so it's very helpful to know that this is a good way of doing it.
@Rutu01 that's exactly what I wanted to suggest - store the value that you receive in async way in some kind of variable and use it when prefiltering is running.
I have a Payer field which I need to custom filter based on Owner of the Record ( So that only Banks belonging to the same parent business unit as the Owner Team Or Third Party Payers like Tax Professionals and Sister Companies can be the Payer). I think i have it working now, i removed the async await from the callback, and instead put all the async operations like retrieveRecord in the Owner On Change event and stored that in a global variable. Now the callback is not async and so the presearch is working as expected. I hope this is a good workaround. Thank you for your comment, I thought it must be something simple I'm missing but guess it's not. If you have any suggestions please let me know
Hello,
I understand what are you talking about, I experienced similar challenges and unfortunately usage of async/await doesn't address the issue.
Can you please provide what you want to achieve so I can help with architecting the solution?
stampcoin
15
ankit_singhal
11
Super User 2025 Season 1
mmbr1606
9
Super User 2025 Season 1