Hi community,
I have a custom button inside Form that leads to a custom Method.
This Method calls a second client Method with aras.evalMethod.
The second Method does a few checks and then opens a "confirm" dialog. User have to press OK or cancel the dialog.
The overall concept works fine, but I cannot get a valid result of the aras.evalMethod call. The second Method shall return the result of the selected dialog option. But the first Method doesn´t wait for the result of the second Method. So my result will be empty / undefined.
First Method
const args = "";
const result = aras.evalMethod("MySecondMethod", document.thisItem, args);
if (typeof result == "object" || result === false)
{
return;
}
alert(result); // We immeditelly get this alert after the Method call. It will be empty, as the dialog it self wasn´t resolved yet.
// Other code, e.g. hide a button
const el=document.getElementById("myelement");
el.style.visibility = "hidden";
Second Method
[...]
window.ArasModules.Dialog.confirm(message, dialogOptions).then(
function(res)
{
switch (res)
{
case 'ok':
dosomething();
return true;
default:
return false;
}
});
I tried using promises and async/await. But so far aras.evalMethod never waited for anything.
I could merge the two Methods, but currently the second Method is called from multiple contexts. So this is something I want to avoid if possible.
Does anyone has an idea that could work to improve the situation?
Thanks!
Angela