- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-31-2019 05:28 AM
I need to add the reply email to the additional comments of the incident in inbound action...The below code doesn't work...Please help
if (email.from.toLowerCase().indexOf("@xxxx.com") >= 0)
{
increply();
}
if (email.from.toLowerCase().indexOf("@yyyy.com") >= 0)
{
increply();
}
function increply(){
if (current.getTableName() == "incident") {
var bodyText = email.body_text;
if (!bodyText)
bodyText = email.body_html;
current.comments = "Reply from: " + email.origemail + "\n\n" + email.subject + "\n\n" + bodyText;
current.update();
}
}
Solved! Go to Solution.
- Labels:
-
Team Development
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-31-2019 06:17 AM
you've declared bodyText here: "var bodyText = email.body_text;"
then you've said, ~if I don't have bodyText here: "if (!bodyText)"
because you did declare it then there will always be a bodyText so you will never run the code inside that If statement
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-31-2019 05:40 AM
Hi,
Is this inbound email action getting triggered?
Did you add log and check?
Mark ✅ Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-31-2019 05:45 AM
You may need to use .setJournalEntry() in your script. Try this:
if (email.from.toLowerCase().indexOf("@xxxx.com") >= 0)
{
increply();
}
if (email.from.toLowerCase().indexOf("@yyyy.com") >= 0)
{
increply();
}
function increply(){
if (current.getTableName() == "incident") {
var bodyText = email.body_text;
if (!bodyText)
bodyText = email.body_html;
current.comments.setJournalEntry("Reply from: " + email.origemail + "\n\n" + email.subject + "\n\n" + bodyText);
current.update();
}
}
For more about .setJournalEntry() see here.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-31-2019 05:46 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-31-2019 06:17 AM
you've declared bodyText here: "var bodyText = email.body_text;"
then you've said, ~if I don't have bodyText here: "if (!bodyText)"
because you did declare it then there will always be a bodyText so you will never run the code inside that If statement
You may need to use .setJournalEntry() in your script. Try this:
For more about .setJournalEntry() see here.