The CreatorCon Call for Content is officially open! Get started here.

How to use event.parm1 from one notification to the other notification

miro2
Mega Sage

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?

1 ACCEPTED SOLUTION

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

View solution in original post

12 REPLIES 12

Kieran Anson
Kilo Patron

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

 

Hi @Kieran Anson 

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);
}

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

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 

find_real_file.png