Access Scratchpad from Switch Core Activity -Kingston

Mike160
Kilo Contributor

New at ServiceNow, but not with programming/javascript.

 

I have a workflow in which I have a Run Script activity that sets a variable value in the ScratchPad (workflow.scratchpad.exec2approve = 'OPS';. In a subsequent Switch Activity, I want to access the value of that variable, but when I type in workflow.scratchpad.exec2approve I get an invalid reference message.

Is there a way to do this? If not, is there a better way to set a value in one activity and access it in a switch activity?

 

Thanks!

1 ACCEPTED SOLUTION

Daniel Oderbolz
Kilo Sage

It's hard to believe, but it really cannot be done (up to Kingston, at least).

In my opionion, Service Now should implemennt the ${} notation to allow to use a workflow variable in Switches (or in any Workflow related context, such as Conditions, where it also does not work).

Hopefully, with the new "Flow Designer" all this is solved...


If this answer was helpful, I would appreciate if you marked it as such - thanks!

Best
Daniel

View solution in original post

10 REPLIES 10

It's what I did, but I can't get anything to match in a switch statement in the If activity's script.

Abhinay Erra
Giga Sage

Can you post your code here

NathanStorm1
Giga Contributor

i believe this example explains it.  How do i make this switch see the value set in the previous activity?

 

find_real_file.png

This is the solution i came up with, but this gets ugly quickly the more choices there are.

 

find_real_file.png

Doing this is throwing an error as "WORKFLOW is not defined" 

Please assist I am not from development background I feel I am missing something minor here