- 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
02-01-2023 08:52 PM
Hi,
I have a similar requirement , i tired following the above steps,
(function executeRule(current, previous /*null when async*/ ) {
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]);
//you can call the gs.eventQueue function here
gs.eventQueue('SendMailToSupplier/Customer', current, current.variables.customer_supplier, '');
gs.log('event working'+current.customer_supplier);
}
can you suggest what logic i am missing, because notifications are not triggering.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-01-2023 10:17 PM
Hi,
I have a similar requirement , i tired following the above steps,
(function executeRule(current, previous /*null when async*/ ) {
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]);
//you can call the gs.eventQueue function here
gs.eventQueue('SendMailToSupplier/Customer', current, current.variables.customer_supplier, '');
gs.log('event working'+current.customer_supplier);
}
can you suggest what logic i am missing, because notifications are not triggering.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-02-2023 05:01 AM
Hi,
I have a similar requirement , but I am missing some logic, can you please help
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-17-2023 02:54 AM
Hi,
I have used the below code to send email to requestor which is in multi row variable set.
var mvrs = current.Variables.user;
mvrs = JSON.parse(mvrs);
for (var i = 0; i < mvrs.length; i++) {
gs.info(mvrs[i].mrvs_email);
gs.eventQueue('x_890866_lims_sano.test multi row user', current, current.Variables.user.email, ' ');
}
can you let me know, where i am doing the mistake.