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

send notification to MRVS variable(user) and List collector

si21
Tera Guru

Hi experts,

We have two requirements after submitting record producer to create a HR case

1. Send notification to user selected in Mutlirow variables set records on a record producer.

2. Send notification to all the users selected in a LIST collector variable on a record producer.

 

How can we achieve this.

 

TIA

2 ACCEPTED SOLUTIONS

Moin Kazi
Kilo Sage
Kilo Sage

Hi @si21 ,

 

  1. Multi-row Variable Set Notification:

    • Create a Business Rule that triggers after the record producer is submitted.
    • In the script, access the multi-row variable set:

 

var multiRow = current.variables.multi_row_variable; // Replace with your variable name
if (multiRow) {
    var userId = multiRow[0].user; // Access the user field from the first row
    if (userId) {
        // Send notification to the selected user
        gs.eventQueue('your.notification.event', current, userId, null);
    }
}

 

 

       2. LIST Collector Variable Notification:

  • In the same Business Rule, add code to handle the LIST collector variable

 

var listUsers = current.variables.list_collector_variable; // Replace with your variable name
if (listUsers) {
for (var i = 0; i < listUsers.length; i++) {
var user = listUsers[i];
// Send notification to each user
gs.eventQueue('your.notification.event', current, user, null);
}
}

 

 

In both examples, replace 'your.notification.event' with the actual notification event you’ve defined in ServiceNow.

 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

If you found my response **helpful**, I’d appreciate it if you could take a moment to select **"Accept as Solution"** and **"Helpful"** Your support not only benefits me but also enriches the community.

 

Thank you!
Moin Kazi

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

 

View solution in original post

Brad Bowman
Kilo Patron
Kilo Patron

You can do this in a Business Rule after Insert on the RP table.  To send to each user in an MRVS:

var mrvs = current.variables.mrvs_internal_name; //use your MRVS name
var rowCount = mrvs.getRowCount();
for (var i=0; i<rowCount; i++){
    var row = mrvs.getRow(i);
    gs.eventQueue('event.name', current, row.variable_name, null); //use your event name and MRVS variable name
}

And, to send to each user in a list collector variable:

var usrArr = current.variables.variable_name.toString().split(','); //use your list collector variable name
for (var j=0; j<usrArr.length; j++) {
    gs.eventQueue('event.name', current, usrArr[j], null); //use your event name
}

 

View solution in original post

10 REPLIES 10

 

Hi @Moin Kazi , thanks for the response. It's working but displaying sys_id? (duplicate too)

si21_0-1729695457249.png