Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

SetAbortAction is not Working on Record Producer in Scoped Application

Raviteja Kunal1
Tera Expert

I am trying to use current.setAbortAction(true) in a Record Producer in a scoped application but is throwing the below error.

 

setAbortAction.jpg

Tried adding Application Cross Scope Access but not working, any reference to fix is this?

 

Thank You

 

5 REPLIES 5

eddy42
Tera Expert

I know this response is somewhat late but I've read loads of posts on this and suddenly came up with a workaround that got me what I wanted - but it's a bit out there.  I want to update a sys_user record from a scoped app record producer and not create a new record.

 

I suddenly got to thinking - I don't want the record producer to create a record but it creates a new record because  I can't use setAbortAction on that global table - so, don't use that table.  (stick with me)

 

So I set the table on the record producer to a table in my scoped application (doesn't matter which as we'll never create a record) and then use current.setAbortAction(true); at the end of the script - so it NEVER creates a record.

Then use an if statement to determine if we should create a new record or not - and do it in code...  solved!

This snippet creates a new user if the new_record variable is true, but if it's not it doesn't create a record anywhere - it updates the existing user specified in the existing_user variable.

if (producer.new_record=true){
  var grUser = new GlideRecord('sys_user');
  grUser.initialize();
  grUser.name=producer.name;
  grUser.update();
}else{
   var grUser = new GlideRecord('sys_user');
    if (grUser.get(producer.existing_user){
      grUser.name=producer.name;
      grUser.update();
    }
}
current.setAbortAction(true);

 

Am I going mad or is this an easy way around this issue?