- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-30-2023 08:28 AM
Hello
I want to store a variable in session level in ServiceNow script include. Actually I want to assign some value to a variable in one script include and access it in another script include. How to do this
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-30-2023 08:43 AM
Set Valye in session Variable
gs.getSession().putClientData('myData', 'Hello, world!');
Read Value
alert(g_user.getClientData('myData'));
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-30-2023 08:43 AM
Set Valye in session Variable
gs.getSession().putClientData('myData', 'Hello, world!');
Read Value
alert(g_user.getClientData('myData'));
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-30-2023 08:51 AM
can we use
alert(g_user.getClientData('myData'));
in different script include?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-30-2023 09:01 AM - edited ‎05-30-2023 09:02 AM
No, g_user is a client side object.
Try this in a script include
gs.getSession().getClientData('myData')