Business rule issue
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-11-2025 12:03 AM
I have a business rule when a parent state is updated it will updated the related child record states now the issue is when the parent have no child records I'm showing an error "No child records present" otherwise I'm updating the child records. here issue is even after having the child records under a parent still it is showing error message and updating the state both things are running what mistake I made help me
when to run "AFTER UPDATE"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-11-2025 12:11 AM - edited ‎06-11-2025 12:12 AM
Hi @maheshchokkara ,
Please make the BR as before BR update, it will work.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-11-2025 01:09 AM
Thanks for the response I Tried No luck.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-11-2025 01:12 AM
current.state.changes() please use the fallowing method in the if condition.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-11-2025 12:13 AM
update as this
(function executeRule(current, previous /*null when async*/ ) {
if (previous.state != current.state) {
var childRecords = new GlideRecord('x_1086067_financia_financial_object');
childRecords.addQuery('parent', current.sys_id);
childRecords.query();
var hasChildren = false;
while (childRecords.next()) {
hasChildren = true;
childRecords.state = current.state;
childRecords.update();
}
if (!hasChildren) {
gs.addErrorMessage('No child records present');
}
}
})(current, previous);
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader