GMSC Discussions

GeoMedia Smart Client community discussion board is where you can create, contribute and share information and knowledge in regards to configuring as well as working with GeoMedia Smart Client. Find your answers, share your knowledge and help build a strong GeoMedia Smart Client community.
Showing results for 
Search instead for 
Do you mean 
Reply
Regular Contributor
Posts: 170
Registered: ‎07-07-2016
Accepted Solution

Closing application problem

[ Edited ]

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?

Contributor
Posts: 23
Registered: ‎01-31-2018

Re: Closing application problem

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')".

Regular Contributor
Posts: 170
Registered: ‎07-07-2016

Re: Closing application problem

Thanks, now it works perfectly!