- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-10-2023 07:41 AM
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?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-10-2023 08:02 AM
@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.
ServiceNow Community Rising Star, Class of 2023
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-10-2023 07:54 AM
Hello @AnetaR ,
Please check the below link which will help to write the script for MVRS.
Bascially, you need to get the Variable and JSON parse that values in client script once you do it. You can pass the values in script include and trigger the notification via event. Where your event parameter will be values parsed i.e email id.
In this way you can try to achieve this requirement.
Thank you,
Omkar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-11-2023 12:34 AM
Hello @AnetaR ,
Can you please mark this correct. So that the thread will be closed.
Thanks,
Omkar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-10-2023 08:02 AM
@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.
ServiceNow Community Rising Star, Class of 2023
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-01-2023 08:39 PM
Hi,
I have a similar requirement to send notification to emails which are in multivariable set.
I followed the steps as you mentioned , but notifications are triggering ,
(function executeRule(current, previous /*null when async*/ ) {
// Add your code here
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]);
gs.eventQueue('SendMailToSupplier/Customer', current, current.variables.customer_supplier, '');
gs.log('event working');
}
})(current, previous);
I think some logic is missing ,but i could not rectify it can you please help me .
Thanks in Advance.