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

Hi @Community Alums 

Few changes to be made in the script (line 1 and line 6)i have corrected those and the functionality is working fine now. 

Thank you 

Hi @Sai Gopal / @Community Alums , I have same requirement and followed the code. Notification is sent to MRVS users but I want to include mrvs username inside email body. For that I have used the code mentioned in this post in emailscript which did not work. Please let me know how to achieve this.