How to use session variable in service now
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-18-2022 05:36 AM
Hello Community,
Can anyone help us one rela time senario by using session variables in service now.
It would be helpful if any one provide code with one realtime example.
Thanks,
Nagesh
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-18-2022 05:41 AM
hello,
Below thread has a good example of use if session in Servicenow:-
https://community.servicenow.com/community?id=community_question&sys_id=1df9cb29db5cdbc01dcaf3231f96196e
Please mark answer correct/helpful based on Impact.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-18-2022 05:52 AM
Hi
you can store values in the session for any caching purposes. For example, after users logs in you could store the user's company name in the session and reuse it in any user criteria. That way, the time-consuming loading of the user properties can be prevented.
Store a value in the session object
var session = gs.getSession();
session.putClientData('<KEY>', '<VALUE>');
Load a value from the session object:
var session = gs.getSession();
var strValue = session.getClientData('<KEY>');
Let me know if you have any further questions.
Kind regards
Maik
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-24-2022 07:26 PM
Hi
In case you think I was able to answer your question, I would be happy if you mark the appropriate response as "correct" so that the question will appear as resolved for other users who may have a similar question in the future.
If not, please tell me what you are still missing.
Many thanks & kind regards
Maik