We've updated the ServiceNow Community Code of Conduct, adding guidelines around AI usage, professionalism, and content violations. Read more

If To or CC is caller then add email body in additional comment

Samiksha2
Mega Sage

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

8 REPLIES 8

can u share what did you try so far and were your struck ?


☑️ Please mark responses as HELPFUL or ACCEPT SOLUTION to assist future users in finding the right solution....

LinkedIn - Lets Connect

Hi @Sohail Khilji ,

It is working fine.
I updated the script.

var callerId = current.contact.email;
        if ((email.copied.contains(callerId)) || (email.to.contains(callerId))|| (email.from.contains(callerId))) {
            current.comments = "Reply from: " + email.origemail + "\n\n" + email.body_text;

            current.update();
        }

Thanks,
Sam

Kindly make the answer as accepted as it my help future reader...


☑️ Please mark responses as HELPFUL or ACCEPT SOLUTION to assist future users in finding the right solution....

LinkedIn - Lets Connect

Samiksha2
Mega Sage

Hi All,
Please help.

 

Thanks,

Sam