03-25-2019 05:32 AM - edited 03-25-2019 06:31 AM
Hi,
In GMSC 2016 SP4 I'm trying to create a form, that automatically checks some condition and if condition is false than closes GMSC application.
So I've created js script that runs after form ready event:
IG.vent.on('form:ready', function(form)
{
if(/*condition*/)
IG.closeSmartClient();
});
But IG.closeSmartClient(); doesn't work. (If I call IG.closeSmartClient(); directly from button action, than it works.)
Anyone have idea how to solve this problem?
Solved! Go to Solution.
03-25-2019 12:36 PM
Hullo mzebrows,
Have you tried to let your code be triggered by the 'smartclient:ready' global event instead of 'form:ready'?
Since IG.closeSmartClient() is calling into a ScriptingObject of the Java client, its not enough to have the web page loaded, but requires all scripting objects to be available to the JavaScript engine of the user agent.
Therefore
IG.vent.on('smartclient:ready', function() { if (/*condition*/) { IG.closeSmartClient(); } });
shall do it.
In addition, I would recommend to wrap the function body of global event handlers with a try-catch block and log any caught error to get a notification if anything goes wrong - doing so in your form:ready handler will give you something like "TypeError: undefined is not an object (evaluating 'SCDefaultScriptingObject().closeSmartClient')".
03-25-2019 11:25 PM
Thanks, now it works perfectly!