- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-21-2024 05:40 AM
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
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-21-2024 11:37 PM
Hi @si21 ,
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
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-23-2024 04:44 AM
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
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-21-2024 06:45 AM
You will have to use Flow Designer to achieve this because your multi-row variable set will spit out an array and you will need to loop over this array to get the Users specified and also get their email.
You might need a custom action in Flow Designer for this.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-21-2024 06:46 AM
How are these users logged on the case? Or are you creating cases for every user on the MRVS and LIST? Are you creating the case(s) from the RP script or is it handled through a flow?
The many different ways of how this can be processed, makes it hard to give concrete answer.
Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-21-2024 11:37 PM
Hi @si21 ,
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
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-23-2024 04:14 AM
Hi @Moin Kazi , I tried LIST Collector Variable Notification: code but it is not working as expected!