Business rule is not working when unchecked the Run Business rule from the transform Map
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-28-2023 03:50 AM - edited 07-28-2023 05:02 AM
Hi,
I have noticed that once i have disabled the Run Business Rule checkbox from transform map, any business rule written on the targeted table is not running.
Below is the business rule-
(function executeRule(current, previous /*null when async*/) {
var gr = new GlideRecord("sn_hr_core_case");
gr.addQuery("u_order_number",current.u_order_number);
gr.query();
while (gr.next()) {
gr.u_location=current.u_location;
gr.u_job_code=current.u_job_code;
gr.update();
gr.setWorkflow(false);
}
})(current, previous);
Whenever a order number/loc/code is inserted or updated via a data load, BR is not working
@Ankur Bawiskar :could you please help...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-28-2023 05:53 AM - edited 07-28-2023 05:55 AM
That is expected behavior. If you unchecked Run Business Rule checkbox from transform map, any Business Rule from that table won't run.
If you want any specific BR to be executed, you have to explicitly create Transform Script based on requirement.
In your case you can create onAfter Transform Script as below:
var gr = new GlideRecord("sn_hr_core_case");
gr.addQuery("u_order_number",target.u_order_number);
gr.query();
while (gr.next()) {
gr.u_location=target.u_location;
gr.u_job_code=target.u_job_code;
gr.update();
gr.setWorkflow(false);
}
Thanks
Anubhav Ritolia
ServiceNow Rising Star 2023
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-28-2023 06:14 AM
Hi @AnubhavRitolia : I have tried with the onAfter script, but the data load was taking much time around 3hrs for 3k records
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-28-2023 06:34 AM
Transform would take time based on scripting and other factors. There may be some more scripting and configuration.
Was it taking 3 hours before this script also is it happening after creating this script only?
Also in which table is your Transform map?
Thanks
Anubhav Ritolia
ServiceNow Rising Star 2023
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-30-2023 10:30 PM
That's correct. For your BR to run that checkbox has to be enabled.
What is the target table for your transform map?
If it's HR Case then why not use onBefore to set the fields?
Why to use onAfter?
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader