- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-03-2020 01:03 AM
Hi
I've got two different notification and workflow using two Run scripts
In the first run script I store callers in array and using parm1 to send emails to them.
Second run script collects some records as a parm2 and should send email to the same callers like parm1.
Anyone knows how to deal with it? How to use parm1 from first run script to the second one?
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-03-2020 04:58 AM
Hi,
Then use this code
Thanks,
var recList = [];
var queryString = 'type=normal';
var gr = new GlideRecord("change_request");
gr.addEncodedQuery(queryString);
gr.query();
while (gr.next()) {
recList.push(gr.sys_id + '');
}
var abc = workflow.scratchpad.parameter1;
var spl = abc.split(',');
for (var i = 0; i < spl.length; i++) {
gs.eventQueue('rec_list', null, spl[i], recList);
}
Thanks,
Ashutosh

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-03-2020 01:07 AM
Hi Miro,
If the run scripts run one after the other, you could save parm1 value in the workflow scratchpad before passing it to the event. Add the below code to the first run script:
workflow.scratchpad.variableName = variableValue;
In the second script run script you can then use the following to call the value and pass it as parm1
workflow.scratchpad.variableName
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-03-2020 01:28 AM
Hi
is that good solution?
first run script
var callers = [];
var encodedString = 'type=normal';
var gr = new GlideRecord("change_request");
gr.addQuery(encodedString);
gr.query();
while (gr.next()) {
callers.push(gr.requested_by.email.toString());
}
var arrayUtil = new ArrayUtil();
callers = arrayUtil.unique(callers);
for(var i = 0; i < callers.length; i++){
workflow.scratchpad.parameter1 = callers[i];
gs.eventQueue('reminder.event', null, callers[i], '');
}
second runscript
var recList = [];
var queryString = 'type=normal';
var gr = new GlideRecord("change_request");
gr.addEncodedQuery(queryString);
gr.query();
while (gr.next()) {
recList.push(gr.sys_id + '');
}
for (var i = 0; i < recList.length; i++) {
gs.eventQueue('rec_list', null, workflow.scratchpad.parameter1, recList);
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-03-2020 01:41 AM
HI,
You need to change the first run script as below:
var callers = [];
var encodedString = 'type=normal';
var gr = new GlideRecord("change_request");
gr.addQuery(encodedString);
gr.query();
while (gr.next()) {
callers.push(gr.requested_by.email.toString());
}
var arrayUtil = new ArrayUtil();
callers = arrayUtil.unique(callers);
for(var i = 0; i < callers.length; i++){
gs.eventQueue('reminder.event', null, callers[i], '');
}
workflow.scratchpad.parameter1 = callers.toString();
Thanks,
Ashutosh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-03-2020 03:17 AM
The problem is that callers are in loop and depends on array length they receive emails equal numbers of records recList (in second run script)
e.g I've got 100 records in recList and callers receive 100 same emails
How it possible?
In my personal dev instance it's looks like below, on rec_list parm1 should be only one sys_id