gs.isInteractive() is not working as expected

Joy1
Giga Contributor

Can someone help me troubleshoot the following business rule? I use gs.isInteractive() to make sure that it runs when the user logs in the platform but not when in a non-interactive session. But it does run when the user submits a request and the log statement shows "gs.isInteractive(): true".

By the way, it's on Kingston.

Befrore query table sc_req_item.

(function executeRule(current, previous /*null when async*/) {

gs.log('gs.isInteractive():' + gs.isInteractive());

if (!gs.isInteractive()) { 

gs.log('!gs.isInteractive():' + !gs.isInteractive());

return;

}

// do some processing here

})(current, previous);

 

Any help would be much appreciated.

 

Joy

1 ACCEPTED SOLUTION

Please close the thread by marking my response correct if it worked for you


Please mark this response as correct or helpful if it assisted you with your question.

View solution in original post

14 REPLIES 14

Please close the thread by marking my response correct if it worked for you


Please mark this response as correct or helpful if it assisted you with your question.

sachin_namjoshi
Kilo Patron
Kilo Patron

please use below method for finding interactive session.

gs.getSession().isInteractive();

 

https://developer.servicenow.com/app.do#!/api_doc?v=jakarta&id=r_GlideSessionIsInteractive

 

Regards,

Sachin

Just tried it. It still shows true.

RAHUL Khanna1
Mega Guru

when user submits ..it is a intereactive session so it runs and it turn out be true ...so whats the issue here

I thought the submission is not an interactive session because the insert is done via workflow. I only want the BR to run when the user accesses the list at back-end not at the submission time due to performance concern. So I used gs.isInteractive() to differentiate these two sessions. But as others pointed out these two are all interactive sessions. I need to find other ways to accomplish this. If anyone has insight on how to do this, it would be greatly appreciated.