Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

How to access workflow scratchpad variables from client script?

Not applicable

Has anyone done this? Thanks in advance.

6 REPLIES 6

rajini3
Kilo Contributor

I have done this and it works great.

In my workflow, I am assigning the value of approval_date to workflow scratchpad variable
var approval_date = sysapproval.u_approved_on.getGlideObject().getNumericValue();
workflow.scratchpad.approval_date = approval_date;

You need to create a "display" business rule to access your workflow scratchpad variable
http://wiki.service-now.com/index.php?title=Business_Rules#Display_Business_Rules

var workflow = new Workflow();
var context = workflow.getContexts(current);
if (context.next()) {
g_scratchpad.approvalDate = context.scratchpad.approval_date;
}

Then you can access the "g_scratchpad.approvalDate" in your client script.

Thanks,
Rajini


I am having trouble coming up with use cases for this. Anything you would want on the form and in the workflow to me seems like a reasonable field addition.

Can anyone provide some examples of how they would use this? I have used the scratchpad to story sys_id's for records generated from another workflow but cannot come up with a specific use case for sharing between g_form/workflow scratchpads.

Either way, Rajini thanks for posting an update on how to do this. Great reference for others!