I have a simple jsonRpcService with a method that returns true or false.
I have a button with code at CCJS and SSJS events. I want to stop code execution if RPC is returning true, however, it looks code is triggered before addCallBack is finished and code at SSJS or is being executed
Is there any way to wait for addCallBack response before continuing with any other CCSJ instruction or SSJS code. I was expecting that return false will stop any code execution.
Here my code:
var lastupdate = '#{javascript:document1.getDocument().getLastModified().toString();}';
var myobject = rpcDocLock.checkUpdate(lastupdate);
myobject.addCallback(function(modified){
alert(modified); // #2
if (modified){
alert("This document has been modified."); // #3
return false;
}
});
alert("This alert is triggered and RPC has not finished its execution.") // #1
I added 3 alerts so you can see the order they are being executed.