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 01:06 AM
No luck, Still the same.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-11-2025 12:15 AM
It is a After Update Br means it will get executed after the record updated in the system. At that time previous object will not be available so that's the reason.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-11-2025 01:08 AM
It is a After Update Br means it will get executed after the record updated in the system. At that time previous object will not be available so that's the reason.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-11-2025 01:17 AM
Hi @maheshchokkara,
Add Condition to your BR that it should run when State changes. And run the following
(function executeRule(current, previous /*null when async*/ ) {
var childRecordsGR = new GlideRecord('x_1086067_financia_financial_object');
childRecordsGR.addQuery('parent', current.sys_id);
childRecordsGR.query();
var hasChild = false;
while (childRecordsGR.next()) {
hasChild = true;
childRecordsGR.state = current.state;
childRecordsGR.update();
}
if (!hasChild) {
gs.addErrorMessage('No child records present');
}
})(current, previous);
That way BR will trigger if State is changed and record is inserted.
Regards,
Ehab Pilloor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-11-2025 03:04 AM
(function executeRule(current, previous /*null when async*/ ) {
//gs.addErrorMessage("hello");
if (current.state.changes()) {
var childRecords = new GlideRecord('incident');
childRecords.addQuery('parent_incident', current.sys_id);
childRecords.query();
var hasChildren;
if(childRecords.hasNext()){
while (childRecords.next()) {
childRecords.state = current.state;
childRecords.setWorkflow(false);
childRecords.update();
}
}
else{
//gs.addInfoMessage(hasChildren);
gs.addErrorMessage('No child records present');
}
}
})(current, previous);
Hi @maheshchokkara ,
Use the above code I tested in my PDI , please change the table name and the parent field name