- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-06-2022 02:41 PM
Desired Solution: I need a business rule to trigger on the core_company table to glide over to another table and update a value on that table. The matching condition is a value called the 'u_branchkey' which is a 3 digit number.
I've gone through the code a few times, tried a few different solutions but nothing seems to be successful in getting the action to function as expected.
I've confirmed in my testing, that the field 'u_branchkey' is accurate and exists on both the core_company and the u_agency_it_state_tracker tables. The value is 100 for both, so as far as I understand, the query should be going to the agency table, and finding what matches 100, then proceeding to update that record.
I've successfully been able to create/insert records on the table so I know the communication to the target table isn't hindered (we also have other processes that work and communicate with our agency table).
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-06-2022 02:54 PM
You don't need "==" in your business rule script.
Update your code like gr.addQuery('u_branchkey',current.u_bkey);
Also, i hope that this custom branch key field on company table is a reference field to your custom table in which you are updating records.
Regards,
Sachin

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-06-2022 10:08 PM
Hi,
try below one
(function executeRule(current, previous /*null when async*/) {
var branch_key = current.u_branchkey;
// var encodedquery = "short_descriptionLIKE"+branch_key; // if branch key is string field try this instead addQuery
var gr = new GlideRecord('u_agency_it_state_tracker');
gr.addQuery('u_branchkey', branch_key);
//gr.addEncodedQuery(encodedquery);
gr.query();
while(gr.next()){
gr.setValue('u_helpdesk', "onboarded");
gr.update();
}
// or use gr.updateMultiple();
})(current, previous);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-07-2022 09:21 AM
Yep this solution would have worked as well, thank you for your input, much appreciated!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-15-2024 01:19 PM
Hi everyone,
It sounds like you're facing an issue where your After Business Rule is not updating records as expected. Here's a troubleshooting checklist that might help:
Check Conditions and Filters: Ensure that the conditions in your rule are correct and that they apply to the records you intend to update. Sometimes, a small condition mismatch can prevent the rule from triggering properly.
Use the current.update Command: In After Business Rules, make sure you're explicitly calling current.update. Since it runs after the database action, failing to include this can prevent the record from being updated.
Avoid Recursive Updates: If your rule triggers another update on the same table, ensure it’s not causing a recursive loop. ServiceNow includes safeguards against this, but always check the System Logs to confirm no recursion warnings.
Review Script Logic: Check the script’s logic carefully. A missed line or syntax error could prevent the update from happening.
Verify Field Access: Make sure the user role running the business rule has proper access to update the fields in question.
Check Other Business Rules or Workflows: Sometimes, other business rules or workflows might interfere. Disable them temporarily to see if they’re causing the issue.
Debugging Tools: Use gs.log statements or the Script Debugger in ServiceNow to trace your rule’s execution path.
Feel free to share your rule’s script if you’re still having trouble. I’d be happy to help further!
Best regards,
Ahsan Ul Haq
Griffin Resources