- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-31-2018 10:14 AM
Hi All,
hoping someone can help with this... basically what I want to do is do a glide record query and loop through returned results to set a workflow.scratchpad variable with a .name of a returned gr.value
ie, creating a workflow.scratchpad variable with the variable's name equal to the value of gr.number for example
say looping through 3 glide record results on the incident table I want to set variables like the below
workflow.scratchpad.INC0001011 = someOtherValue;
workflow.scratchpad.INC0001012 = anotherOtherValue;
workflow.scratchpad.INC0001013 = yetAnotherOtherValue;
so that later on in my workflow I can reference the value of workflow.scratchpad.INC0001012
conceptually I want something like this, but I believe its just going to keep overwriting workflow.scratchpad.varName
function setVariable(varName, value) {
workflow.scratchpad.varName = value;
}
anyone have any suggestions on how to do this, or suggestions on other ways to set a dynamic list of workflow.scratchpad.variables? Any help greatly appreciated!
Ajay
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-31-2018 10:24 AM
here is an example, looping through a GR. This sample will create properties on scratchpad that are the sys_id (getUniqueValue()) of each record, and the value of that property gets set to the display value of that record.
while (gr.next()) {
workflow.scratchpad[gr.getUniqueValue()] = gr.getDisplayValue();
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-31-2018 10:22 AM
workflow.scratchpad is a js object, so you can get/set properties on a JS object one of 2 ways:
- workflow.scratchpad.name = value;
- workflow.scratchpad['name'] = value;
and for getting the values using option 2:
return workflow.scratchpad['name'];
Option 2 is the way to go for your use case

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-31-2018 10:24 AM
here is an example, looping through a GR. This sample will create properties on scratchpad that are the sys_id (getUniqueValue()) of each record, and the value of that property gets set to the display value of that record.
while (gr.next()) {
workflow.scratchpad[gr.getUniqueValue()] = gr.getDisplayValue();
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-31-2018 11:03 AM
thanks jon, you rock!