Mass update through script without calling Business Rules and Events

Chris York
Tera Expert

Is there a way to execute a background script (From Scripts - Background) that updates a record but does not run the business rules on that table?

For example, I have a new field on the Incident table that is a calculated field. However, the calculated value does not get set until the Incident is saved. I want to run a script that does an update on all existing Incident records, but I don't want to trigger any events or business rules as a result of the update.

var gr = new GlideRecord('incident');
gr.query();
while (gr.next()){
gr.update();
}

1 ACCEPTED SOLUTION

Mark Stanger
Giga Sage

You should be able to use the 'setWorkflow' method like this. It says to not run any business rules with the update.



var gr = new GlideRecord('incident');
gr.query();
while (gr.next()){
gr.setWorkflow(false);
gr.update();
}


View solution in original post

5 REPLIES 5

Thank you for the two great suggestions, Mark. They are certainly very helpful.
In addition to those I've learned from another experienced SN developer that gr.addNullQuery('field_name'); can be used to query records for empty fields more efficiently than gr.addQuery('field_name', '=', 'NULL');

Thanks again for the quick response!