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 send notification to the users who are listed in a multi row variable set

Sai Gopal
Tera Contributor

Hi Experts,

 

I have created a catalog item in which i have used multirow variable set and it has a variable - "Requested for",

after submitting the form a RITM is being created, whenever this RITM goes to closed complete state a notification should be sent to all the users who are in the requested for field of my multi row variable set.

 

I am not finding anything related to the variable set in my flow designer Get catalog variables, Can anyone suggest me what i should be doing here for sending notification.

 

SaiGopal_0-1716215842708.png

 

 

Thank you 

 

2 ACCEPTED SOLUTIONS

Community Alums
Not applicable

Hi @Sai Gopal ,

 

You can use below script to parse MRVS & get the emails

 

var emails =[];
var mvrs = current.variables.variableSetName;
mvrs = JSON.parse(mvrs);
for(var i=0; i<mvrs.length; i++){
emails.push(mvrs[i].emailFieldName);
}
gs.eventQueue("EventName",current,emails);
 
 
Trigger the notification by event & check "Event parm 1 contains recipient" checkbox.
 
Sai149_0-1716217837313.png

 

 

I started answering community questions recently. If my answer helped you in any way, please mark it as helpful or correct. It would be a great boost.

View solution in original post

Community Alums
Not applicable

@Sai Gopal Yes you can do that.

In the email script write the below code

 

var recipientSysIds = event.param1.split(',');
var recipientNames = [];

for (var i = 0; i < recipientSysIds.length; i++) {
  var grUser = new GlideRecord('sys_user');
  grUser.addQuery('sys_id', recipientSysIds[i]);
  grUser.query();

  if (grUser.next()) {
    recipientNames.push(grUser.getValue('name'));
  }
template.print("Hi "+recipientNames);

 

If my answer helped you in any way, please mark it as helpful or correct.

View solution in original post

6 REPLIES 6

Vengadesh
Tera Guru

Hi @Sai Gopal ,

 

You can use the Get catalog variable and get the values of MRVS and then use for each logic to send notification to the users

Community Alums
Not applicable

Hi @Sai Gopal ,

 

You can use below script to parse MRVS & get the emails

 

var emails =[];
var mvrs = current.variables.variableSetName;
mvrs = JSON.parse(mvrs);
for(var i=0; i<mvrs.length; i++){
emails.push(mvrs[i].emailFieldName);
}
gs.eventQueue("EventName",current,emails);
 
 
Trigger the notification by event & check "Event parm 1 contains recipient" checkbox.
 
Sai149_0-1716217837313.png

 

 

I started answering community questions recently. If my answer helped you in any way, please mark it as helpful or correct. It would be a great boost.

Hi @Community Alums ,

I have created a BR and triggering a notification, it is being sent to all the individuals but in the email body after "Hi" i am trying to give the recipient's name, is it possible give the names?

Thank you

Community Alums
Not applicable

@Sai Gopal Yes you can do that.

In the email script write the below code

 

var recipientSysIds = event.param1.split(',');
var recipientNames = [];

for (var i = 0; i < recipientSysIds.length; i++) {
  var grUser = new GlideRecord('sys_user');
  grUser.addQuery('sys_id', recipientSysIds[i]);
  grUser.query();

  if (grUser.next()) {
    recipientNames.push(grUser.getValue('name'));
  }
template.print("Hi "+recipientNames);

 

If my answer helped you in any way, please mark it as helpful or correct.