Custom Inbound Email Account not creating incidents: did not create or update incident using current

mgraden
Tera Contributor

I've created a custom Inbound Email Action to create Incidents from PrinterLogic alert emails, but I can't seem to get to work, instead it keeps using the OOB one. Priority is set to 50 to fire before the OOB one, but I keep getting the following error within the email log: PrinterLogic Email Alerts: did not create or update incident using current

 

Setting with the action:

Target Table: Incident

Action type: Record Action

Application: Global

Active: True

Type: New

Execution Order: 50

 

Below is the script I currently have: 

 

function runAction(current, email, inboundAction, scope) {

    var from = (email.origemail || "").toLowerCase();

    // Only handle PrinterLogic emails
    if (from.indexOf("printerlogic.com") === -1) {
        return; // allow OOB inbound email action
    }

    // Populate the incident record
    current.short_description = email.subject;

    current.description =
        "PrinterLogic Alert\n\n" +
        "From: " + email.origemail + "\n\n" +
        email.body_text;

    current.category = "hardware";
    current.subcategory = "printer";
    // sys_id of PrinterLogic account
    current.caller_id = "8ee6c9273b000b10fb698f9a04e45a86";
    current.impact = 2;
    current.urgency = 2;
 
    // Insert Incident
    current.insert();

    // Stop processing to avoid the OOB action from firing.
    event.state = "stop_processing";
}
4 REPLIES 4

Ankur Bawiskar
Tera Patron

@mgraden 

did you try disabling the OOTB one and see if your works?

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

I have, I still get the same error message "did not create or update incident using current" in the email log and now no incident is created since the OOB one is disabled. 

Hello @mgraden 

Keep oob "Create Incident" disabled and update your script to remove:

1.   event.state = "stop_processing";
2. 

    // Only handle PrinterLogic emails
    if (from.indexOf("printerlogic.com") === -1) {
        return; // allow OOB inbound email action
    }

Use below:
6.jpg


If this works, then enable the oob and validate again.

My recommendation is to go for flow instead of inbound email action. As there maybe a possibility that many use cases may arise over a period of time which will end up modifying the script. For example avoid duplicate incident creation if same e-mail is sent multiple times. You may already know this that with flow there are many oob actions which can suffice such use cases.


Hope that helps!

Tanushree Maiti
Kilo Patron

Hi @mgraden 

 

1) Are you doing anything in scoped App. In that case set following property to true.

set glide.record.legacy_cross_scope_access_policy_in_script

2) event state is deprecated long back. It could be the cause that it is not running.

3)Ensure your trigger condition is properly mentioned and  is getting triggered properly.  

like Subject contain create incident

Note: Check the Received mail for details.

 

You can write script or Field Action for the mapping under Action tab .

I find Field action is a bit easy as it is NO Code.

Sample :

Screenshot 2026-04-13 212140.png

 

 

4) Disable OOB inbound email action.

Please mark this response as Helpful & Accept it as solution if it assisted you with your question.
Regards
Tanushree Maiti
ServiceNow Technical Architect
Linkedin: