Stop processing an inbound action

peg612
Giga Contributor

I have created an inbound action that is inside scope and I need it to stop processing after it runs. I have added "event.state="stop_processing";" and that normally works in global but it does not appear to be working in scope.


I checked the logs and found this:

org.mozilla.javascript.EcmaError: "event" is not defined.

Caused by error in Inbound Email Actions: 'Create HSC Incident' at line 30

27: }

28:

29: current.insert();

==> 30: event.state="stop_processing";

Has anybody seen an issue with stop processing in scope or know of another way to stop processing?

5 REPLIES 5

qz8437
Mega Contributor

Why don't you just check the "Stop processing" box for the Inbound Email Action? Wouldn't that do what you want?


There are several times when the "Stop processing" box is not appropriate. My use case is

inbound action run order 50 checks if the email of type forward contains a valid watermark in the email body. If it does, it updates the existing incident and stops processing

inbound action run order 100 processes email of type forward and creates a new incident

 

In this case I set event.state='stop_processing'; in the first script only if the watermark is found and updated. If I use the "Stop processing" box then the second script will never run.

 

I know that I could just create one big script that both checks if the issue exists and if not creates a new one, but splitting this into two scripts makes the code cleaner.

 

Michael Ritchie
ServiceNow Employee
ServiceNow Employee

Agree with Reed.   The Stop Processing attribute was introduced several releases ago and is the "new" way of stopping the processing of further inbound actions.   More details can be found on this article:


Create an inbound email action


quoccsc
Tera Contributor

I had the same issue, and it's because my inbound action script was in scoped application. When I create the inbound action again in Global, state.event = 'stop_processing' worked as expected.

Note: confirmed in Madrid version, not sure if this is fixed in New York.