Can we use g_scratchpad variable in catalog client scripts.

Sachin Pratap 2
Kilo Expert

Is there a way so that we can use g_scratchpad variable in catalog client scripts.

Or we only have GlideAjax for fetching server side data on catalog client scripts.

1 ACCEPTED SOLUTION

AbhishekGardade
Giga Sage

Hello Sachin,

No we cant use g_scratchpad variable in this case.

scratchpad is a data holder which is on server and client side 

Server - Display Business Rule to put data in scratch pad 

Client - Read data from scratch pad and use it 

https://docs.servicenow.com/bundle/madrid-application-development/page/script/business-rules/concept/c_ScriptingWithDisplayBusinessRules.html

For catalog item form or record producer you should make a GlideAjax call via client script.

Please mark as Correct Answer and Helpful, if applicable.
Thank You!
Abhishek Gardade

Thank you,
Abhishek Gardade

View solution in original post

4 REPLIES 4

Elijah Aromola
Mega Sage

Are you trying to use it to be referenced in a later client script? If so, probably not as it gets cleared out. If you're trying to use an onDisplay business rule and pass information to the client, then yes you should be able to do this.

asifnoor
Kilo Patron

Hi,

Generally g_scratchpad is available on client side only when Display Business Rules are used. If your requirement is to fetch data based on some other action like OnChange, then you have to use Script Include.

Let us know your requirement and may be we can assist you better.

Mark the comment as a correct answer and helpful if this answers your question.

chetanb
Tera Guru

g_scratchpad is an empty/temporary object you can use to push information (properties, objects, functions, custom variables etc.) from the server to the client.
Note:- that information is not available currently on the form
Is run on catalog item tables(s c_cart_item, sc_cat_item)  ? --> You cannot run business rules on catalog items. Hence we cant use g_scratchpad to set values.

 

Mark the comment as a correct answer and helpful if this answer suffice your question.

AbhishekGardade
Giga Sage

Hello Sachin,

No we cant use g_scratchpad variable in this case.

scratchpad is a data holder which is on server and client side 

Server - Display Business Rule to put data in scratch pad 

Client - Read data from scratch pad and use it 

https://docs.servicenow.com/bundle/madrid-application-development/page/script/business-rules/concept/c_ScriptingWithDisplayBusinessRules.html

For catalog item form or record producer you should make a GlideAjax call via client script.

Please mark as Correct Answer and Helpful, if applicable.
Thank You!
Abhishek Gardade

Thank you,
Abhishek Gardade