g_scratchpad

SoniShaily
Tera Contributor

Hey everyone,
I’m trying to use a value from g_scratchpad in a catalog client script, but it keeps coming back as undefined. I’ve set the scratchpad value in a Catalog Server Script on the same item.
Am I missing something?

1 ACCEPTED SOLUTION

Rushi Savarkar
Kilo Sage

Hello @SoniShaily 

Make sure your Catalog Client Script is running after the Catalog Server Script. g_scratchpad is only available on load.
Type = onLoad for the client script.

It won’t work in onChange or onSubmit unless you store the value in a variable.
Also, double-check that your server script is actually populating the value and that it's scoped to the right item or variable set.

Thank you!

If my response helped you, please accept the solution and mark it as helpful.
Thank You!

View solution in original post

5 REPLIES 5

Sandeep Rajput
Tera Patron
Tera Patron

@SoniShaily Are you accessing it in any script other than onLoad, if yes then it is only available in onLoad and not available in onChange or onSubmit.

Shubham_Jain
Mega Sage

@SoniShaily 

 

Use g_scratchpad only in onLoad Catalog Client Scripts

 Make sure your Catalog Server Script sets it properly

Don’t expect it in onChange or onSubmit without workarounds

✔️ If this solves your issue, please mark it as Correct.


✔️ If you found it helpful, please mark it as Helpful.



Shubham Jain


Neeraj31
Mega Sage

@SoniShaily g_scratchpad is not supported in catalog item/ Record producer as we set the g_scratchpad variables in display Business rule. Catalog server script runs when the catalog item is submitted. If you need to fetch data from server, then use GlideAjax call in catalog client script .

 

Please mark as Correct Answer and Helpful, if applicable.

Ankur Bawiskar
Tera Patron
Tera Patron

@SoniShaily 

g_scratchpad works only in display business rule and won't work on catalog side.

what's your business requirement?

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader