Inbound Email Action: Update Incident if Incident Number is in the subject.

Scott29
Kilo Sage

I am trying to create an inbound email action that updates an existing Incident if the Incident Number is in the subject line. So far no luck getting it to process my test email.

 

For the "When to run" condition: /INC\d{7}/.test(email.subject)

 

Action:

 

var regex = /INC\d{7}/;
    var match = regex.exec(email.subject);
    var incidentNumber = match ? match[0] : null;

    if (incidentNumber) {
        var gr = new GlideRecord('incident');
        gr.addQuery('number', incidentNumber);
        gr.query();
Scott29_1-1753330376960.png

 


        if (gr.next()) {
            // Update existing incident
            gr.work_notes = "Updated via inbound email: " + email.body;
            gr.update();
        }
    }
Scott29_0-1753330367059.png

 



 

9 REPLIES 9

Ankur Bawiskar
Tera Patron
Tera Patron

@Scott29 

there is already an OOTB inbound email action on incident of type Reply and it updates the INC.

The incoming email match against the target INC happens via watermark

Any reason you are not using that OOTB inbound email action?

AnkurBawiskar_0-1753331365621.png

 

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Yes, this will not be a reply email, so the watermark will not be in the body. I am attempting to target the Incident Number in the subject.

 

Have you checked your inbound email logs and found which Inbound email action got executed while attempting

 

Steps to verify:

System Mailboxes > Inbound > Received.

Open the email which you sent to your instance. and Verfiy email logs related list if some other inbound action got executed

@Scott29 

Since it won't be a type Reply and if it's a NEW email then how would that person know the INC number?

That's not how Reply inbound works.

If an email is sent from INC001 and user responds to that same email, system will determine the target record as INC001 and will update it.

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader