How to mass trigger a Business Rule

RYang
Kilo Contributor

I had a requirement to create a new field in Chnage that would show the number Releases that are related to it. I did this through an 'after' business rule in Release that would provide the count and update the appropriate field within the Change Record if the "Parent" field is updated.

The Business rule works fine for any new relations. However any historical records do not provide a count of the related records. Is there any way I can trigger the business rule to run en mass to update all of the records?

Thanks!

3 REPLIES 3

CapaJC
ServiceNow Employee
ServiceNow Employee

This should help:
Business Rule Mass Update


gputker
Tera Contributor

Hi,

I needed to run my business rules on the sys_user table for all active records without actually updating the records.  This worked perfectly and with very minimal system impact:


var gr = new GlideRecord('sys_user');  //call the sys_user table

gr.addQuery('active', 'true');  //only update active records

gr.query();

while(gr.next())

{

gr.update();    //make update changes - OF WHICH THERE ARE NONE
gr.setForceUpdate(true);  //force the record to update even though no actual changes have been made

}

 

I dropped the above code into a scheduled job and it works perfectly.  Cheers.

SanjivMeher
Kilo Patron
Kilo Patron

You would need a fix script or background script to do it. You can't run the business rule in mass.

Make sure to set below while updating the record, so that the system fields are not updated. Otherwise it will mess some of your reports and in every record, you will be the Last Updated By.

gr.autoSysFields(false); 

gr.setWorkflow(false);


Please mark this response as correct or helpful if it assisted you with your question.