How to update an existing incident using inbound email action if existing incident mentioned in subj

Naresh_5120
Tera Contributor

Dear community,

 

I am looking for solution to update the existing incident (work notes) using inbound email action if an existing incident mentioned in subject line of an email (It could be New, reply or forward email )

 

Regards,
Naresh

6 REPLIES 6

Sandeep Rajput
Tera Patron
Tera Patron

@Naresh_5120 Please use the following email script to update an existing incident if the subject carries any incident number.

 

var regex = /INC[0-9]+/gi
if(regex.test(email.subject)){
    //get the match
    var matchInc = email.subject.match(regex);
    var glideInc = new GlideRecord('incident');
    glideInc.addQuery('number',matchInc);
    glideInc.setLimit(1);
    glideInc.query();
    if(glideInc.next()){
        //Do something here
        gs.info(glideInc.short_description);
    }
else{
gs.info('Incident with number '+matchInc+' not found');
}
    
}
else{
    gs.info('Subject does not contain incident number ');
}

Dear @Sandeep Rajput 

 

Thank you for your quick response. I have tried this script but it is creating new incident instead of updating an existing incident. Am I missing something

 

Do i have to use when to run Type as "None"

Naresh_5120_0-1711973568172.png

 

 

@Naresh_5120 Ideally, the None type should process all the types (New, Reply and Forward) here is the article https://www.servicenow.com/community/developer-blog/inbound-action-with-type-and-target-table-set-to.... covering the None type usage.

 

Regarding your issue, did you check if there any existing inbound actions on your incident table which is creating new incident? if yes then try and deactivate them or reduce the order of your current inbound action and set the stop processing checkbox to true so that the other inbound actions will not get processed.