whenever parent is closed, child should also close automatically

ShivaK548811677
Tera Contributor

How to do this in flow design.

7 REPLIES 7

Rafael Batistot
Tera Sage

Hi @ShivaK548811677 

 

May you try vi Business Rule 

 

 

  • Table: the table where parent/child exists (e.g., incident)
  • When: after
  • Condition: when the parent state changes to Closed
  • advanced checked 
  • script:

(function executeRule(current, previous /*null when async*/) {

// Run only if the parent is moved to "Closed"
if (current.state.changesTo('7')) { // '7' = Closed in Incident table, adjust for your table

// Query child records
var childGR = new GlideRecord('incident'); // replace with your table if different
childGR.addQuery('parent_incident', current.sys_id); // adjust field name
childGR.addQuery('state', '!=', '7'); // only those not already closed
childGR.query();

while (childGR.next()) {
childGR.state = current.state; // set same state as parent
childGR.close_code = current.close_code; // optional, copy close reason
childGR.close_notes = 'Closed automatically when parent was closed.';
childGR.update();
}
}

})(current, previous);

 

 

this is an example, but you can ajust for you scenario 

ShivaK548811677
Tera Contributor

No I need to do this in flow design

@ShivaK548811677 ,

 

Above explained in flow designer.

 

Do want to do in workflow or flow designer ?

 

Thanks,
Bhimashankar H

 

-------------------------------------------------------------------------------------------------
If my response points you in the right directions, please consider marking it as 'Helpful' & 'Correct'. Thanks!

Bhimashankar H
Mega Sage

Hi @ShivaK548811677 ,

 

 

  1. Choose the  "Update Record".

  2. Add condition: state changes to Closed (e.g., state becomes Closed or equivalent closed state value).

 

  1. Use the "Look Up Records" action.

  2. Select the child table (records you want to close automatically).

  3. Add a condition linking child to the parent. For example, parent field (reference) equals current record’s sys_id.

 

  1. Add a "For Each" loop action, iterating through the child records found.

  2. Inside this loop, add an "Update Record" action.

  3. Update the child record’s state field to Closed (or equivalent).

 

Thanks,
Bhimashankar H

 

-------------------------------------------------------------------------------------------------
If my response points you in the right directions, please consider marking it as 'Helpful' & 'Correct'. Thanks!