How to add cc'ed users in Watch list using inbound actions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā09-15-2022 05:03 AM
Dear All,
I've an requirement to add cc'ed users in email to watch list using inbound actions. it's working for me when i add a single user in cc, but if i had multiple users like 5 and all its not working.
Can someone help me on this. below is the code
var userArray = [];
var copied = email.copied.split(',');
for (var i = 0; i < copied.length; i++) {
gs.info("CC'ed email Address " + copied);
var contact = new GlideRecord("sys_user");
contact.addQuery('email', copied);
contact.query();
if (contact.next()) {
userArray.push(contact.getUniqueValue().toString());
}
//current.internal_user = contact.getValue("sys_id");test
current.short_description = email.subject;
current.description = email.body_text;
current.contact_type = "email";
current.assigned_to = email.copied;
current.watch_list = userArray.toString();
current.insert();
}
Regards,
Suvarna
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā09-15-2022 05:07 AM
hi @Suvarna
Try this:
var userArray = [];
var copied = email.copied.toString().split(','); //changed here
for (var i = 0; i < copied.length; i++) {
gs.info("CC'ed email Address " + copied);
var contact = new GlideRecord("sys_user");
contact.addQuery('email', copied[i]); //changed here
contact.query();
if (contact.next()) {
userArray.push(contact.getUniqueValue().toString());
}
}
//current.internal_user = contact.getValue("sys_id");test
current.short_description = email.subject;
current.description = email.body_text;
current.contact_type = "email";
current.assigned_to = email.copied;
current.watch_list = userArray.toString();
current.insert();
Thanks,
Murthy
Murthy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā09-15-2022 05:52 AM