Where we can declare scratchpad variable.How it would be retraived?

paramesh048
Kilo Contributor

Hi to all  I have doubt where we declare scratchpad and what is the purpose of that?

7 REPLIES 7

Sanjay Bagri1
Tera Guru

Hi ,

If you want to pass the value from one activity  to another  activity so in this case we will use the scratch pad in workflow . 

 

The scratchpad in workflow is a space in the workflow context to store and share string based variables (as name:value pairs) between instances of activities within an executing instance of a workflow.

The scratchpad is global to the instance of the running workflow and as such, is available equally to all activities.

The scratchpad itself is automatically available to an executing workflow and requires no specific declaration. Variables are declared and stored in the scratchpad simultaneously by referencing it. For example:

workflow.scratchpad.variableName = variableValue;




If my suggestion helped then please Mark the correct & helpful.
so other community members can benefit from this information.

Thanks
Sanjay Bagri

||DxSherpa Tech. ||

Hi there,

For viewing actual scratchpad content used in the Platform UI, there's a nice and easy to apply tool "Show Contents of g_scratchpad".

Kind regards,
Mark

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

LinkedIn

Thanks your response but  Paramesh wants to know the use of scratchpad which is useful in Workflow to pass the values from one activity to another .

but g_scratchpad is usable in Display Business rules to call the business rules in client side.

both are different scratchpad and g_Scratchpad 

 

Thanks 

Sanjay Bagri

Viraj Hudlikar
Tera Sage

Hi,

you got 2 different scratchpads

 

1. The scratchpad that is used to send information between a display business rule and a client script/UI Policy. This is pretty much an alternative to making a GlideAjax Call on the client script instead. If you know you need data that isn't available on the form, you can run the code in a display business rule put the data in the scratchpad and the fetch that data when it's needed in the client script. Just beware that it might be better with GlideAjax in some cases. This since when using scratchpad, you get the data how it looked when the business rule queried it. It might perhaps be 5 min afterwards and for example your onsubmit client script needs the data. Then it can be old data which has been changed.

 

2. Scratchpad i workflow. This is used to send data between activities. Otherwise you can reach data that was fetch/calculated etc. from a earlier activity.