- 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 04:10 AM
Hi @Prudhvi Raj4 ,
Please check in user record if Darby Hughes and Araceli Berudez have email id sys_user table. I think that users don't have email in their record.
Please mark my answer correct and helpful if this works for you.
Thanks and Regards
Sarthak
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-16-2024 04:39 AM
Hi @Community Alums
Yes, I have checked on sys_user table emails ID's are present
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-16-2024 04:27 AM
Hi @Prudhvi Raj4 ,
Please re-check the code logic, there is while over result set and again for loop which.
Also check the user record as suggested by @Community Alums .
Why you need two arrayList object, where you are pusing one arrayList object to other one.
You just need email from gliderecord query and trigger the eventQueue for each iteration.
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);
}
},
-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
05-16-2024 04:41 AM
Hi @AshishKM
I have two different arrays because in the first array I have duplicate email ID so I am removing the duplicate and storing them in second array and using it