Inbound Action: updating incident

kemmy1
Tera Guru

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

 

1 ACCEPTED SOLUTION

SanjivMeher
Kilo Patron
Kilo Patron

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.

View solution in original post

6 REPLIES 6

vkachineni
Kilo Sage
Kilo Sage

Could be a missing } of if(){ after the current.update();

Please mark Correct and click the Thumb up if my answer helps you resolve your issue. Thanks!
Vinod Kumar Kachineni
Community Rising Star 2022

vkachineni
Kilo Sage
Kilo Sage

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);

 

 

Please mark Correct and click the Thumb up if my answer helps you resolve your issue. Thanks!
Vinod Kumar Kachineni
Community Rising Star 2022