I have a client action, which calls a server action inside. And the problem is, when I attempt to call that from JS with setTimeout() like this:
window.setTimeout(function() {
$actions.Action();
}, $parameters.Timeout);
It fails with this error:
Uncaught (in promise)
message: "No role validation found"
name: "System.InvalidOperationException"
However, if I call the same action from normal client action or javascript - this doesn't happen. I suppose, normally it uses user information from context, but when called from setTimeout - that is not available. I tried to debug inside the server action, but breakpoint was not hit.
Does anyone know if there is a workaround for this?
Hi Igor,
I think the reason for your problem might be because you didn't include a $resolve(); in your Javascript. This is necessary uses Async execution of JS function.
Attached a working application that delays the execution of a client action 5 seconds, and then displays a hello message.
Here is also the documentation then explains that you have to resolve or reject the promise (the client action().
https://success.outsystems.com/documentation/11/integration_with_external_systems/javascript/defining_asynchronous_javascript_code/
Regards,
Daniel
Thank you, adding resolve solved the problem.
Even though I don't understand how it is related to the error, but the main thing is that it works.
Hey Igor,
did you end up with a solution for this?
I'm having the same issue, it looks like the action runs, but it creates that "No role validation found" error log.
Do you know if we could at least catch that error and not log it?
Thanks,
Nelson
Hi Nelson. No, I gave it up and not using setTimeout in that case. I had to do what I wanted to do in a different way.
Why do you need the setTimeout?
Because I wanted to execute an action after a delay.
I have client actions in expressions in different parts of the screen. They can (or can not) add values to a javascript array, which I then need to send to server. The idea was to start a wait on first such addition, then few seconds later send whatever was accumulated. Instead, I had to add a call in OnReady. Sometimes it gets executed before all those functions are done, so it's not fully reliable, but there should be another OnReady later... I don't have any better idea yet.