event.state = "stop_procesing" not working in SCOPED APP

reginabautista
Kilo Sage

Hello everyone,

I've developed a scoped application that handles inbound actions based on configuration records. Here's an overview of the processes it performs:

  1. It checks the configuration records to determine if it meets the conditions for ignoring incoming emails.

  2. It checks the configuration records to identify conditions for checking duplicates. If a match is found, it updates the target record.

  3. It also reviews the configuration records to identify conditions for creating or updating target record.

My goal is to effectively manage the execution of other inbound actions based on the criteria above. I've added the event.state = "stop_processing" to stop further processing, but I'm encountering a challenge where other inbound actions continue to run despite having the event.state = "stop_processing" in place.

 

Sample code that creates/update target record:

 

(function runAction(/*GlideRecord*/ current, /*GlideRecord*/ event, /*EmailWrapper*/ email, /*ScopedEmailLogger*/ logger, /*EmailClassifier*/ classifier) {
try{
gs.info('Start running Inbound Action - Process Email - New');
 
var siUtils = new InboundActionUtils();
/*Find the email received so we can pass the email GR object to the matchFilterConditions function. 
This is needed as GR is required to pass to the match filter*/
var email_sys_id = sys_email.sys_id;
var grEmail = new GlideRecord("sys_email");
if(grEmail.get(email_sys_id)){
 
var bIncProcessed = siUtils.processInboundActionConfigRecords(grEmail,logger,false,email);
if(bIncProcessed){
//if incident is found then stop processing
gs.info('Completed processing Inbound Action - Process Email - New');
event.state="stop_processing";
}
}
}catch(e){
gs.info('Error in Inbound Action - Process Email - New ' + e);
}
})(current, event, email, logger, classifier);
 
 
 
Note:
I can see the message "Completed processing Inbound Action - Process Email - New'" which means the condition in the if block retured true.
The "Ordered Email Processing" plugin is installed.
 
Has anyone encountered this issue? Any help is greatly appreciated.
 
Thanks,
Regina
1 ACCEPTED SOLUTION

reginabautista
Kilo Sage

Setting the below system property to true seems to have fixed the issue:
glide.record.legacy_cross_scope_access_policy_in_script

https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0779287

View solution in original post

3 REPLIES 3

Omkar Mone
Mega Sage

Hello,

 

Is this script been processed from scoped application? Can you check the logs what errors are you seeing?

Hi Omkar, yep it is a scoped app and I don't see any errors in the log...

 

Thanks,

Regina

reginabautista
Kilo Sage

Setting the below system property to true seems to have fixed the issue:
glide.record.legacy_cross_scope_access_policy_in_script

https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0779287