- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-15-2019 10:09 AM
I've gone through (I think) ALL of the docs and community posts about this, but for some reason this is not working for me. This is a "New" inbound action (no watermarks)
An email is sent (no watermark) with the Incident number to update in the body of the email. I've tried a couple of ways to update the Incident and it's not working:
This doesn't do anything:
(function runAction(/*GlideRecord*/ current, /*GlideRecord*/ event, /*EmailWrapper*/ email, /*ScopedEmailLogger*/ logger, /*EmailClassifier*/ classifier) {
var id = email.body.email_incident;
var inc = new GlideRecord('incident');
inc.addQuery('number', id);
inc.query();
if(inc.next()) {
inc.work_notes = "this is a comment3333";
inc.update();
}
})(current, event, email, logger, classifier);
-------------------------------------------------------
This creates a new incident not updates it:
(function runAction(/*GlideRecord*/ current, /*GlideRecord*/ event, /*EmailWrapper*/ email, /*ScopedEmailLogger*/ logger, /*EmailClassifier*/ classifier) {
var id = email.body.email_incident;
var inc = new GlideRecord('incident');
inc.addQuery('number', id);
inc.query();
if(inc.next()) {
inc.work_notes = "this is a comment3333";
current.update();
}
})(current, event, email, logger, classifier);
------------------------------------------------------------
I created a log and email.body.email_incident does pull out the correct incident number, so it IS finding the incident number (I also used a background script to make sure it finds the record as well).
Any ideas?
Lisa
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-15-2019 10:17 AM
Hi Lisa,
Is this the complete code? I don't see a reason this to be not working. Are you sure, the email is entering your inbound action. Please some logs to it, to make sure it does
gs.info('+++++inside my inbound action+++++'+email.body.email_incident)
var id = email.body.email_incident;
var inc = new GlideRecord('incident');
inc.addQuery('number', id);
inc.query();
if(inc.next()) {
inc.description = "this is a comment3333";
inc.update();
}
Please mark this response as correct or helpful if it assisted you with your question.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-15-2019 10:17 AM
Hi Lisa,
Is this the complete code? I don't see a reason this to be not working. Are you sure, the email is entering your inbound action. Please some logs to it, to make sure it does
gs.info('+++++inside my inbound action+++++'+email.body.email_incident)
var id = email.body.email_incident;
var inc = new GlideRecord('incident');
inc.addQuery('number', id);
inc.query();
if(inc.next()) {
inc.description = "this is a comment3333";
inc.update();
}
Please mark this response as correct or helpful if it assisted you with your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-15-2019 12:03 PM
Yes, the email_incident is definitely coming through. I did a gs.log("LAK " + id).
Here is my complete code (I updated my original question as well):
(function runAction(/*GlideRecord*/ current, /*GlideRecord*/ event, /*EmailWrapper*/ email, /*ScopedEmailLogger*/ logger, /*EmailClassifier*/ classifier) {
var id = email.body.email_incident;
var inc = new GlideRecord('incident');
inc.addQuery('number', id);
inc.query();
if(inc.next()) {
inc.work_notes = "this is a comment3333";
current.update();
}
})(current, event, email, logger, classifier);

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-15-2019 10:47 AM
Hi,
What is the type of this inbound email action?
New, Forward or Reply or none?
Thanks,
Ashutosh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-15-2019 12:01 PM
It's new and there is no watermark. Forgot to add that!