Change Parent State based on Child tasks state
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-24-2024 01:29 PM
Hello Experts,
From scheduled job we are creating 1 Parent Record along with 2 Tasks under it with Task 1 Type as "Code Review" and Task 2 Type as "Test Review". Also, when we have a 'state' field on those tasks with dropdown options as 'Update', 'Not Required', 'Done'.
so, when those two tasks are updated with 'state' as 'Done' then the 'State' on Parent record should be updated as 'Closed'.
But If 'Code Review' type of task state is set to 'Update' OR 'Retire' and 'Test Review' type of task state is set to 'Update' OR 'Retire' then state on Parent record should be update as 'Review Revision'.
I believe this should be done by after BR. but need help on how script should look like.
Thanks,
Ben.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-24-2024 01:39 PM
@Ben42 ,
On child table you can create after update Business rule and Glide record to parent and set the value based on condition,
Here i have tried on Ritm(parent) and child (sc_task)
(function executeRule(current, previous /*null when async*/ ) {
var ritm = new GlideRecord('sc_req_item'); // parent table
ritm.addQuery('sys_id', current.request_item); //here query the sys id of parent table with child table reference field
//gs.addInfoMessage("line num " + current.request_item);
ritm.query();
if (ritm.next()) {
ritm.state = '3'; //set state with closed complete backened value
// ritm.closed_at = current.closed_at;
ritm.update();
}
})(current, previous);
Please mark this comment as Correct Answer/Helpful if it helped you.
Regards,
Swathi Sarang