Send notification to email addresses in Multi-Row Variable set

AnetaR
Tera Contributor

Hi, I'm quite new to SN scripting so would appreciate your help on the below.

 

On a record producer I have a very simple MRVS with just one column for email addresses (they are external to our user db hence I cannot grab them from the system). 

 

For the sake of excercise let's agree that:

* the Internal Name of the MRVS is 'mrvs_name'

* the email variable on the MRVS is 'mrvs_email'

 

How can I grab the emails submitted in the MRVS into the recipients field on the notification?

 

1 ACCEPTED SOLUTION

jaheerhattiwale
Mega Sage
Mega Sage

@AnetaR Trigger notification using the gs.eventQueue function and pass the recipient in the parm.

 

Documentation for gs.eventQueue function: https://developer.servicenow.com/dev.do#!/reference/api/quebec/server/c_GlideSystemScopedAPI

 

to get email in mvrs in business rule you can have below code.

 

var mvrs = current.variables.mrvs_name;

mvrs = JSON.parse(mvrs);

 

for(var i=0; i<mvrs.length; i++){

gs.info(mvrs[i].mrvs_email);

//you can call the gs.eventQueue function here

}

 

Please mark as correct answer if this solves your issue.

Please mark the answer as correct or helpful based on impact
ServiceNow Community Rising Star, Class of 2023

View solution in original post

8 REPLIES 8

Hi, 

I have a similar requirement , i tired following the above steps,


(function executeRule(current, previous /*null when async*/ ) {


var mvrs = current.variables.emailaddress;
gs.log('email---'+ mvrs);
mvrs = JSON.parse(mvrs);
for (var i = 0; i < mvrs.length; i++) {
gs.log(mvrs[i].customer_supplier);
gs.log('mvrs---'+mvrs[i]);

//you can call the gs.eventQueue function here
gs.eventQueue('SendMailToSupplier/Customer', current, current.variables.customer_supplier, '');
gs.log('event working'+current.customer_supplier);

}

NeelavathiM_0-1675313104994.png

 

can you suggest what logic i am missing, because notifications are not triggering.

NeelavathiM_1-1675313519202.png

 

Hi, 

I have a similar requirement , i tired following the above steps,


(function executeRule(current, previous /*null when async*/ ) {


var mvrs = current.variables.emailaddress;
gs.log('email---'+ mvrs);
mvrs = JSON.parse(mvrs);
for (var i = 0; i < mvrs.length; i++) {
gs.log(mvrs[i].customer_supplier);
gs.log('mvrs---'+mvrs[i]);

//you can call the gs.eventQueue function here
gs.eventQueue('SendMailToSupplier/Customer', current, current.variables.customer_supplier, '');
gs.log('event working'+current.customer_supplier);

}

NeelavathiM_0-1675313104994.png

 

can you suggest what logic i am missing, because notifications are not triggering.

NeelavathiM_1-1675313519202.png

 

Hi,

I have a similar requirement , but I am missing some logic, can you please help

Hi,

I have used the below code to send email to requestor which is in multi row variable set.

var mvrs = current.Variables.user;

mvrs = JSON.parse(mvrs);

 

for (var i = 0; i < mvrs.length; i++) {
gs.info(mvrs[i].mrvs_email);
gs.eventQueue('x_890866_lims_sano.test multi row user', current, current.Variables.user.email, ' ');
}

 

can you let me know, where i am doing the mistake.