- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-20-2020 03:14 AM
Hello,
What is the use of gs.getSession and where do we use it, can anyone explain me in detail as i am new to servicenow.
Regards,
Tejaswini
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-20-2020 11:07 AM
You can view some detailed information here
basically gs.getSession() is used in a server-side script in order to return details about the currently logged in user's session.
Common uses are to check if the user has an interactive sessions (viewing things in the browser) using isInteractive()
Determine if the current user is impersonating someone with isImpersonating()
And to set data server-side that you can later retrieve client-side using putClientData().
Server-side you would normally follow something like
var session = gs.getSession()
session.putClientData('my_data_name', 'myDataValue');
You would do this in a Before business rule typically, and then client-side you would retrieve the data with
g_user.getClientData('my_data_name') which would return the string "myDataValue".
Typically you would use this to pre-populate data from the server that you might need client-side without having to initiate a query and wait for a response.
Beyond that, you tend to learn more about sessions when you find a need to interact with them.
If this was helpful, or correct for you, please be kind and remember to click appropriately!
Michael D. Jones
Proud member of the GlideFast Consulting Team!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-20-2020 11:07 AM
You can view some detailed information here
basically gs.getSession() is used in a server-side script in order to return details about the currently logged in user's session.
Common uses are to check if the user has an interactive sessions (viewing things in the browser) using isInteractive()
Determine if the current user is impersonating someone with isImpersonating()
And to set data server-side that you can later retrieve client-side using putClientData().
Server-side you would normally follow something like
var session = gs.getSession()
session.putClientData('my_data_name', 'myDataValue');
You would do this in a Before business rule typically, and then client-side you would retrieve the data with
g_user.getClientData('my_data_name') which would return the string "myDataValue".
Typically you would use this to pre-populate data from the server that you might need client-side without having to initiate a query and wait for a response.
Beyond that, you tend to learn more about sessions when you find a need to interact with them.
If this was helpful, or correct for you, please be kind and remember to click appropriately!
Michael D. Jones
Proud member of the GlideFast Consulting Team!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-21-2020 10:25 AM
How do i use getClientData() in server side? I am trying
var session = gs.getSession();
var event = session.getClientData('my_data_name');
But its not working
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-30-2024 04:09 PM
hello @ServiceNow SA
To getClientdata() ... you should first putClientdata in getSession()
firstly it should run function which consists of putClientdata('my_data_name','my_data_value');// adding name and value
then in another function we can use getClientdata() to get value.