Fix script causes workflows and business rules to run?

jamesmcwhinney
Giga Guru

I am trying to run a fix script to set a new custom flag on all of my requested items and requests from false to true.

However, when I run my fix script, it seems to cause workflows to run, notifications to kick off,. etc.

I don't want this to happen when I run the script, is there any easy way to avoid this?

Here is what I have so far:

Fix Script

//Get all requested items which are IT=false and for which the catalog item is part of the catalog "Service Catalog"
//Update the RITM such that IT=True
var ritm = new GlideRecord('sc_req_item');
ritm.addEncodedQuery('cat_item.sc_catalogsLIKEe0d08b13c3330100c8b837659bba8fb4');
ritm.addQuery('u_department_it','false');
ritm.setLimit(10); //Start with 10 at a time to be safe
ritm.setWorkflow(false); //Do not run business rules
ritm.autoSysFields(false); //Do not update system fields
ritm.query();
while (ritm.next()) {
ritm.u_department_it = true;
ritm.update();
}

//Get all requests which are IT=false and which have a requested item which has IT=true
//Update the request such that IT=true
var req = new GlideRecord('sc_request');
req.addQuery('u_department_it','false');

// Where the request contains associated RITMs
var grSQ = req.addJoinQuery('sc_req_item','sys_id','request');
// And the RITM records are IT
grSQ.addCondition('u_department_it', 'true');
req.setLimit(10); //Start with 10 at a time to be safe
req.setWorkflow(false); //Do not run business rules
req.autoSysFields(false); //Do not update system fields
req.query();
while (req.next()) {
req.u_department_it = true;
req.update();
}

1 ACCEPTED SOLUTION

jamesmcwhinney
Giga Guru

Nevermind.



Looks like the below was actually effective in preventing other events from firing etc:



ritm.setWorkflow(false); //Do not run business rules


ritm.autoSysFields(false); //Do not update system fields


View solution in original post

1 REPLY 1

jamesmcwhinney
Giga Guru

Nevermind.



Looks like the below was actually effective in preventing other events from firing etc:



ritm.setWorkflow(false); //Do not run business rules


ritm.autoSysFields(false); //Do not update system fields