If To or CC is caller then add email body in additional comment
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-08-2024 01:04 AM
Hi All,
I have a requirement to add a condition in the Reply Inbound action if To or CC is caller then add email body in additional comment. Here is my script:
(function runAction( /*GlideRecord*/ current, /*GlideRecord*/ event, /*EmailWrapper*/ email, /*ScopedEmailLogger*/ logger, /*EmailClassifier*/ classifier) {
if (current.getTableName() == "incident") {
if((email.to== current.caller_id) ||(email.copied== current.caller_id)){
current.comments = "reply from: " + email.origemail + "\n\n" + email.body_text;
current.update();
}
}
})(current, event, email, logger, classifier);
Please let me know what I'm doing wrong.
Thanks,
Sam
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-08-2024 01:09 AM
Hi @Samiksha2 ,
Here is the fixed script try i hope it helps...
(function runAction( /*GlideRecord*/ current, /*GlideRecord*/ event, /*EmailWrapper*/ email, /*ScopedEmailLogger*/ logger, /*EmailClassifier*/ classifier) {
if (current.getTableName() == "incident") {
var callerId = current.caller_id.toString();
if ((email.to && email.to.contains(callerId)) || (email.cc && email.cc.contains(callerId))) {
current.comments = "Reply from: " + email.origemail + "\n\n" + email.body_text;
current.update();
}
}
})(current, event, email, logger, classifier);
☑️ Please mark responses as HELPFUL or ACCEPT SOLUTION to assist future users in finding the right solution....
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-08-2024 01:14 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-08-2024 01:24 AM
Hi @Samiksha2 ,
Try to add logs and see whats printing and what is not printing.
if (current.getTableName() == "incident") {
var callerId = current.caller_id.toString();
// Check if the email was sent to or copied to the caller
if ((email.to.indexOf(callerId)) || (email.cc.indexOf(callerId))) {
current.comments = "Reply from: " + email.origemail + "\n\n" + email.body_text;
current.update();
}
}
☑️ Please mark responses as HELPFUL or ACCEPT SOLUTION to assist future users in finding the right solution....
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-08-2024 01:48 AM