Need to execute client script on logout from the instance.

Naveen15
ServiceNow Employee
ServiceNow Employee

Hi,

I need to execute some client script on user clicks logout.

I am integrating an aws deployed application in the platform in iframe in UI pages. This application uses the user's session to login into it. After clicking the logout in the instance, if I am able to execute an ajax call from the client side to logout url of this application, that also gets logged out.

So, all I need to execute a client script on clicking the logout of the instance.

Can any one please help me on this. I am struck here since couple of days.

4 REPLIES 4

Jace Benson
Mega Sage

IF you need just the sessionid from sn, you could do this server side from a script action against the `logout` event as the "Instance ID" is the session ID.

Naveen15
ServiceNow Employee
ServiceNow Employee

Yes, you are right. But I don't need the sessionId. All I need is to execute an ajax call(hit logout url of the application) from the client script to make sure user gets logout from the application on clicking the logout form the instance.

I just need to execute client script on clicking the logout on the instance.

Thank you so much for looking into it. I hope we will get a solution for this.

I don't know how you'd do that.  I suppose you could add a global UI script if user is "guest" run this call.  in a try catch.  That would run on every page load where a user is unauthenticated.  you could try to have it only run on page that url contains `logout.do` but all they need to do is press the stop button on the browser and it will stop running.

rajkumar5
Tera Contributor

Hi,
Can you try with these possiblities.

1) location.href='logout.do';

 

2) openFrameAPI.openCustomURL('logout.do');