Workflow ScratchPad Variables and retrieval

Wade Clairmont
Tera Guru

Hi there,

I have read what I can in the realm of ScratchPad variables and uses, and here is what I required, hoping that some one out there has the elusive answer.

I have a workflow with and if statement before a group approval, where I populate the scratchpad variable, and this all works fine.

answer = checkVariable();

function checkVariable() {
if (current.variables.v_sn_iir.getGlideObject().getValue() == 'true' || current.variables.v_sn_wfl.getGlideObject().getValue() == 'true' || current.variables.v_sn_ncl.getGlideObject().getValue() == 'true' || current.variables.v_sn_fa.getGlideObject().getValue() == 'true') {
workflow.scratchpad.var_iir = 'IIR / WFL / NCL / Facility Audits';
gs.log('IIR / WFL / NCL / Facility Audits SCRATCHPAD: ' + workflow.scratchpad.var_iir);
return 'yes';
}
return 'no';
}

Now, I know the scratchpad variable contains the text, as per the gs.log.  

From there, I need to retrieve this text from that scratchpad variable and insert it into a field on the approval form.  

OnLoad Script on approval form is:

var scratchIIR = workflow.scratchpad.var_iir;
g_form.setValue('u_ritm_approval_for', scratchIIR);

When I load the approval form, there is no value in the custom field (u_ritm_approval_for) I have created.

Any assistance would be greatly appreciated.  Thanks in advance!

4 REPLIES 4

Harsh Vardhan
Giga Patron

workflow.scratchpad object works on server side

you have to use "workflow.scratchpad" object into your workflow activities . 

 

 

you can also access "workflow.scratchpad"  it on business rule, refer the doc link. 

 

https://docs.servicenow.com/bundle/orlando-application-development/page/script/useful-scripts/refere...

Jaspal Singh
Mega Patron
Mega Patron

Hi Wade,

 

workflow.scratchpad will accessible only from the workflow. In your case I would suggest to store it on a field of RITM table. Once done you can use g_scratchpad() that would pass value from RITM to approval table.

 

Thanks,

Jaspal Singh

TimW1
Tera Expert

If you want to view the variables stored in the workflow just open the workflow context from the ticket (under related links) and then go to options and "show xml".  The scratchpad is visible right there.

 

'<scratchpad>{"variablename1":"variablevalue1","variablename2":"variablevalue2"}</scratchpad>'

Medi C
Giga Sage

Hi @Wade Clairmont 

Workflow.scratchpad object is working on Server Side.


If you found this helpful, please hit the thumbs-up button and mark as correct. That helps others find their solutions.