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

Correct, this would be for an inbound email action type = NEW.

@Scott29 

Okay but how would the person sending email know the INC number since that person didn't get any email with that INC in subject line?

you can achieve this requirement but this doesn't sound like a valid business requirement.

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

The email is coming in from an automated system, the system will have the incident number but that is it.

GlideFather
Tera Patron

Hi @Scott29 can you please explain your ambition?

 

Inbound email action is when somebody sends email towards ServiceNow and it will do something, for example create incident. 

I will send an email to the instance, instance will process it and creates INC0001. Why do you want to handle this in the inbound action? It will be automatically.

 

Alternatively, if you configure the email notifications accordingly the sender will receive an automated response "Hello your email has arrived and we register it with INC0001 bla bla bla".

 

Please describe the scenario. Perhaps what you do is not needed at all

———
/* If my response wasn’t a total disaster ↙️ drop a Kudos or Accept as Solution ↘️ Cheers! */


Dr Atul G- LNG
Tera Patron
Tera Patron

Hi @Scott29 

 

https://developer.servicenow.com/dev.do#!/learn/learning-plans/xanadu/new_to_servicenow/app_store_le...

 

Have a look here.

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]

****************************************************************************************************************