best way to declare Global variables on Service Portal (server side)?

Aviv S_
Tera Contributor

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. 

5 REPLIES 5

Pranesh072
Mega Sage
Mega Sage

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. 

you can use $emit, $broadcast events

 

https://serviceportal.io/using-events-communicate-widgets/

DScroggins
Kilo Sage

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