- 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 11:49 AM
Could be a missing } of if(){ after the current.update();
Vinod Kumar Kachineni
Community Rising Star 2022
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-15-2019 12:15 PM
Line 8 is current.update();
it should be inc.update();
//Try
(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);
Vinod Kumar Kachineni
Community Rising Star 2022