I want to pass server side data to client side on service portal.

saurabhchande
Tera Expert

Client side:

client side.PNG

Server side:

Server s ide.PNG

i am getting the values from array in html but I want to use it in client script.

I want to send the values which are in while loop of gliderecord and need to retrieve it in client script. Please help me in both - sending and retrieving. Many thanks.

1 ACCEPTED SOLUTION

Chuck Tomasi
Tera Patron

The common practice is to use the data object (noted in the comments) in your server script.



Example:



data.myNumber = 10;


data.myID = gs.getUserID();



Then in the client script,



var userID = c.data.myID;


View solution in original post

7 REPLIES 7

Dave Smith1
ServiceNow Employee
ServiceNow Employee

Read up about g_scratchpad or Script Includes - they'll be what you're after.



For the latter, you'll pass the information as serialised fields in a JSON object then will need to de-serialise at the other end.



(we actually do this as a lab on our Scripting Course).


saurabhchande
Tera Expert

It's Service portal and not normal modules of Servicenow.


Hi Saurabh,



You can use the data object into the client part of your widget with c.data.variableName



Regards!


Chuck Tomasi
Tera Patron

The common practice is to use the data object (noted in the comments) in your server script.



Example:



data.myNumber = 10;


data.myID = gs.getUserID();



Then in the client script,



var userID = c.data.myID;