- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-16-2024 03:55 AM
Hi Team,
I have requirement to send emails to all the managers for the records in pending approval. I have written a script to get all the managers email ID and using gs.eventQueue sending emails, here few emails are getting triggered and few are not when I check in the event logs I can see for the emails sent parm1 is set to user email id and emails which are not sent parm1 is set to user name, not sure why some are picking emailID and some are user name. please suggest how to fix the issue.
Script to trigger emails
In the above screen shot couple of records are getting email ID and remaining are getting user name where emails are not going out.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-16-2024 05:12 AM
Even if you doing like this ... you should first prepare final arrayList with unique emails and then iterate the arrayList for event trigger.
Try this one.
setDriverPendingEmails: function(){
var driver = new GlideRecord('table name');
driver.addEncodedQuery('status=Pending Approval');
driver.query();
var email_to =[];
var arrayUtil = new global.ArrayUtil();
while(driver.next()){
// push all emails to array
email_to.push(driver.adobe_ldap_id.manager.email.toString());
} // while loop end here
var uniqueEmails = arrayUtil.unique(email_to);
for ( var i=0; i < uniqueEmails.length; i++){
gs.eventQueue('x_adosy_adb_treasu.sendPendingApprovalsEmail',driver,uniqueEmails[i].toString(),null);
} // for loop end here
},
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
‎05-16-2024 05:12 AM
Even if you doing like this ... you should first prepare final arrayList with unique emails and then iterate the arrayList for event trigger.
Try this one.
setDriverPendingEmails: function(){
var driver = new GlideRecord('table name');
driver.addEncodedQuery('status=Pending Approval');
driver.query();
var email_to =[];
var arrayUtil = new global.ArrayUtil();
while(driver.next()){
// push all emails to array
email_to.push(driver.adobe_ldap_id.manager.email.toString());
} // while loop end here
var uniqueEmails = arrayUtil.unique(email_to);
for ( var i=0; i < uniqueEmails.length; i++){
gs.eventQueue('x_adosy_adb_treasu.sendPendingApprovalsEmail',driver,uniqueEmails[i].toString(),null);
} // for loop end here
},
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
‎04-08-2025 02:13 AM
setDriverPendingEmails: function(){ var driver = new GlideRecord('table name'); driver.addEncodedQuery('status=Pending Approval'); driver.query(); //var email_to =[]; //var arrayUtil = []; while(driver.next()){ var email_to = driver.adobe_ldap_id.manager.email.toString(); gs.eventQueue('x_adosy_adb_treasu.sendPendingApprovalsEmail',driver,email_to.toString(),null); } },