best way to declare Global variables on Service Portal (server side)?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā01-17-2021 07:22 AM
Hi
I have many widgets on diff pages on the service portal that use and make the same query (glideRecord query).
The results depend on the current user, and I want to avoid making this calls and just hold the result once (lets say while the user login).
What's the best way without use the GlideSession API?
In other words, I want to extend the GlideUser API that I could get additional info that not exist on this API today.
- Labels:
-
Service Portal Development
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā01-17-2021 08:13 AM
You can use rootscope.This article will help you.
https://community.servicenow.com/community?id=community_blog&sys_id=94ad22a9dbd0dbc01dcaf3231f9619b9
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā01-17-2021 08:23 AM
Hi
tnx for the responding but I dont want to use events like rootscope, this is client side approach.
The meaning is that - in each widget I will have to listen to this event and pass (call) it to the server side of the current widget, so the server side will run while the widget is initiate and again for the event.
I want that already in the initiation I could access these global variables.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā01-17-2021 08:26 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā01-17-2021 12:21 PM
Hello,
For this you can utilize glidesession: https://developer.servicenow.com/dev.do#!/reference/api/orlando/server_legacy/c_GlideSessionAPI
You can use putClientData() method to set whatever values are necessary then use getClientData() method to retrieve the previously set values. Hope this helps.
--David