- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-30-2023 08:09 PM
A have a problem with a change that is not letting me approve it and seems that the issue is a business rule that is running, I'm running a background script just to approve this but I want to know if it is a way to stop the business rule only and let running the workflow?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-01-2023 09:45 AM - edited ‎07-01-2023 09:47 AM
Hi @Abigail,
Yes. this will stop all business rules for the time.
If you want to disable specific business rule:
- You can disable it manually for the time and make it active later.
- You can disable using below scripts before your scripts and make it active after successful script execution.
// Disbale businss rule scritps
var business_rule = new GlideRecord('sys_script');
business_rule.addEncoddedQuery("sys_id=business_rule_sys_id");
business_rule.query();
if(business_rule.next()){
business_rule.active = false;
business_rule.autoSysFields(false);
business_rule.update();
}
// Enable businss rule scritps
var business_rule = new GlideRecord('sys_script');
business_rule.addEncoddedQuery("sys_id=business_rule_sys_id");
business_rule.query();
if(business_rule.next()){
business_rule.active = true;
business_rule.autoSysFields(false);
business_rule.update();
}
Thanks,
Sagar Pagar

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-01-2023 12:13 AM
Hi,
I guess you are trying to change state value for change? If so, there is an OOB BR that is responsible for state model & thus the case. You can use setWorkFlow() as suggested in comments before. Alternatively, the BR name will be displyaed when you execute the script in Background & thus can disable (not recommended) for the script execution & enable again.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-01-2023 12:47 AM
Hi @Abigail,
- Business Rules will run for operations done in scripts, just like any other insert/update/delete.
They could do unexpected things and might make the system slow.
- To stop this, use the below method in your script to avoid triggering any BR on the table being updated. It disables the running of business rules that might normally be triggered by subsequent actions.
obj.setWorkflow(false);
- Additionally, you can use the below method in your script to disable the update to the system fields of the table. For example sys_updated_by, sys_updated_on, sys_mod_count, sys_created_by, and sys_created_on.
obj.autoSysFields(false);
You can refer to the below KB article for more information.
https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0780755
If you feel that I have assisted you in any manner, please mark my comment as helpful/correct.
Thanks,
Shreya