- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-20-2024 04:59 AM
i got a list of managers in a variable in the business rule, and now i want to send a notification to the list of managers who stored in a variable with the email script how do it?
in the email script
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-20-2024 06:34 AM
//Inside Business rule you can write as
var managers = [
{ email: 'manager1@example.com', name: 'Manager 1' },
{ email: 'manager2@example.com', name: 'Manager 2' },
// Add more managers as needed
];
gs.eventQueue('your_event_name',current,current.number,managers);
// inside email template you can use by... managers array with the help of event object....
for(var i=0;i<event.managers.length;i++){
email.addAddress("cc",event.managers[i].email,event.managers[i].name)
}
Do mark my answer helpful and hit the solution button...
Thanks
Saurabh Dubey.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-20-2024 06:08 AM - edited 02-20-2024 06:10 AM
Hi @nabeel55 ,
Use the event based email notification and trigger that event with recipient details in the loop.
In BR, iterate the manager's arrayList and trigger the event for email notification.
-Thanks,
AshishKM
Please mark this response as correct and helpful if it helps you can mark more that one reply as accepted solution
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-20-2024 06:34 AM
//Inside Business rule you can write as
var managers = [
{ email: 'manager1@example.com', name: 'Manager 1' },
{ email: 'manager2@example.com', name: 'Manager 2' },
// Add more managers as needed
];
gs.eventQueue('your_event_name',current,current.number,managers);
// inside email template you can use by... managers array with the help of event object....
for(var i=0;i<event.managers.length;i++){
email.addAddress("cc",event.managers[i].email,event.managers[i].name)
}
Do mark my answer helpful and hit the solution button...
Thanks
Saurabh Dubey.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-22-2024 02:17 AM
Hi @nabeel55 ,
Please refer this code if you are going to implement it... I tried it on my personal instance as well so this will help you.
// Your Business Rule will look like this.
(function executeRule(current, previous /*null when async*/ ) {
var managers = [{
email: 'abraham.lincoln@example.com',
name: 'Abraham Lincoln'
},
{
email: 'aileen.mottern@example.com',
name: 'Aileen Mottern'
},
];
gs.eventQueue('sending_mail_managers', current, current.number, JSON.stringify(managers));
})(current, previous);
// Your email script I have logged the contents so that you can understand
// Add your code here
var mails = JSON.parse(event.parm2);
gs.info("Lets getb the JSON object in cc"+typeof event.parm2);
for (var i = 0; i < mails.length; i++) {
email.addAddress("cc", mails[i].email, mails[i].name);
gs.info("managers arre here "+mails[i].email);
}
// This is the code I have tried it and logged it so you can see the variables
Do mark this solution as accepted and mark this as helpful... so that it can reach to others...
Thanks and regards,
Saurabh Dubey.