Hi I need to map email address of user record with the related list of AD account email address
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-14-2023 03:44 AM
Hi,
I need a compare the user email address in user record with the Ad account email address which is in the related list for user record ,
how can i compare this email address and if there is a difference in the email address i need to send an daily to a particular group
how can i achieve this any suggestion
thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-25-2023 12:08 AM
Hi Saurabh,
// Create a new GlideRecord for sys_user table with an encoded query
var sysUser = new GlideRecord('sys_user');
sysUser.addEncodedQuery('u_account_typeINemployee,contractor^active=true^email_addressLIKEbhn.com,LIKEbhnetwork.com');
sysUser.query();
var matchFound = false; // Initialize the matchFound flag to false
while (sysUser.next()) {
var sysUserEmail = sysUser.email.toString();
// Create a new GlideRecord for u_ad_user_account table with an encoded query
var adUser = new GlideRecord('u_ad_user_account');
adUser.addEncodedQuery('email_address=' + sysUserEmail);
adUser.query();
if (adUser.next()) {
// A match is found, set matchFound to true and break out of the loop
matchFound = true;
break;
}
}
// Send an email outside the loop if no match is found
if (!matchFound) {
var email = new GlideEmailOutbound();
email.setSubject('No Email Match Found');
email.setBody('No matching email addresses found.');
email.addRecipient('group@example.com'); // Add recipient group email address
email.send();
}
am using the script but still when i check the logs am not able to see any emails.
could you please suggest if there is any issue with this script
thanks