
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-12-2010 02:03 PM
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();
}
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-12-2010 02:09 PM
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();
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-12-2010 02:09 PM
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();
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-12-2010 02:23 PM
Thanks Mark. Worked perfectly.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-22-2011 02:13 PM
Hi,
This is certainly very helpful. I'm going to use it in my script.
I am trying to use the following script to perform a mass update on a number of defective INC records. However the script fails to perform the updates. Where am I mistaking?
var gr = new GlideRecord('incident');
gr.addQuery('caller_id', '=', 'NULL');
gr.addQuery('service_offering', '=', 'NULL');
gr.addQuery('assignment_group', '=', 'NULL');
//Use the below line for testing with a smaller set of tickets
//gr.addQuery('number', 'IN', 'INC00zzzzz, INC00zzzzzzz, INC00zzzzzz');
gr.query();
while(gr.next()) {
gs.log('Incident #: ' + gr.number + ' has missing data in mandatory fields');
gr.setWorkflow(false);
gr.caller_id = "something";
gr.service_offering = "something";
gr.assignment_group = "something"
gr.update();
gs.print('Incident #: ' + gr.number + ' has been updated');
gs.log('Incident #: ' + gr.number + ' has been updated');
}
gs.log('TOTAL # of Records processed: ' + gr.getRowCount())

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-22-2011 07:48 PM
The script looks fine to me. Of course, you'll need to replace "something" with an actual sys_id value to get those reference fields populated with something that matters...either that or use 'gr.caller_id.setDisplayValue('Joe Employee');' to use the display value instead.