Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Relogin User with Script

Meloper
Kilo Sage

Hi,

with GlideSessions.lockOutSessionsInAllNodes(user) im able to logout a User.

Is there an Option to logout and login again? <- with script

 

So that the user dont have to do the relogin manually?

 

 

5 REPLIES 5

Ankur Bawiskar
Tera Patron
Tera Patron

@Meloper 

I don't think it's a valid business requirement.

Why would you want a script to login for user?

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Meloper
Kilo Sage

Hi Ankur,

after a special Action of the User, we assign a Role to the User.
Unfortunatly, the User needs to logout and login again, to get the "function" of that new rule.
We would like to find a Solution, so that the User does not have to do any action by themself

Amit Verma
Kilo Patron
Kilo Patron

Hi @Meloper 

 

Try this :

var user = gs.getUser();

// Refresh GlideSession object
GlideSecurityManager.get().setUser(user);

// Refresh GlideUser object
gs.getSession().loadUserByID(user.getID());

 

Refer below posts for reference :

https://www.servicenow.com/community/itsm-forum/glidesecuritymanager-and-service-portal/m-p/817608

https://github.com/zhmur/servicenow-guides/blob/master/Dirty%20hacks.md

 

Thanks & Regards

Amit Verma


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

Wow, thank you, i will try it.
However i cant find this api in developer page: https://developer.servicenow.com/dev.do#!/reference/api/utah/server_legacy/