- 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
‎06-30-2023 09:37 PM
Hi @Abigail,
You have to use the gliderecrdObject.setWorkflow(false); method of GlideRecord.
When you call setWorkflow(false), the business rules get skipped and disabled.
For reference: https://www.servicenow.com/community/developer-forum/what-is-the-use-of-setworkflow-false-scoped-gli...
Thanks,
Sagar Pagar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-01-2023 09:31 AM
Hello i just need to stop a business rule in the activity, this will stop all the business rules trigger on the workflow? or just the one on the activity of the workflow
- 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
‎06-30-2023 10:18 PM
Hi Abigail,
Why cannot you provide a suitable condition for your business rule so that it will not run for your situation? Your problem statement is missing bellow details:
1. What is the action of the BR and when it runs?
2. Why is this BR restricting you not to approve the record?
Thanks & Regards,
Amitra Bhuia