Once sub task is closed then parent task state should change to work in progress
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-22-2024 05:54 AM - edited 02-22-2024 05:55 AM
Hi,
I'm looking into requirement. once the subtask is closed then parent task state should chnage to workinprogress.
Please help me to complete this task.
Parent: sn_si_incident
child: sn_si_task
Regards,
Sanju.
- Labels:
-
Incident Management
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-22-2024 07:03 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-22-2024 06:12 AM
Hello @Talari Balateja -
Please try below code in Business rule:
(function executeRule(current, previous /null when async/ ) {
var newTasks = new GlideRecord("sn_si_task");
newTasks.addEncodedQuery(//add encoded query here to match the parent record on child table);
newTasks.query();
var flag = false;
while (newTasks.next()) {
if (current.state != '3') {
flag = true;
}
}
if (flag == false) {
var grTask= new GlideRecord("sn_si_task");
grTask.addEncodedQuery(//add encoded query here to match the parent record on child table);
grTask.query();
if(!grTask.next()){
var incidentReq = new GlideRecord("sn_si_incident");
if (incidentReq.get(current.number)) {
incidentReq.setValue('state', '//state number for WIP');
incidentReq.update();
}
}
}
})(current, previous);
Please Mark ✅Correct if this solves your query and also mark 👍Helpful if you find my response worthy based on the impact.
Thanks,
Pratiksha
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-22-2024 06:36 AM
Hi @Pratiksha2
I update code like and it's not working. BR AFTER & CONDITION IS STATE CHANGES TO CLOSED COMPLTE
(function executeRule(current, previous /*null when async*/) {
var newTasks = new GlideRecord("sn_si_task");
newTasks.addEncodedQuery('state', 'Closed Complete');
newTasks.query();
var flag = false;
while (newTasks.next()) {
if (current.state != '3') {
flag = true;
}
}
if (flag == false) {
var grTask= new GlideRecord("sn_si_task");
grTask.addEncodedQuery('state', 'Closed Complete');
grTask.query();
if(!grTask.next()){
var incidentReq = new GlideRecord("sn_si_incident");
if (incidentReq.get(current.number)) {
incidentReq.setValue('substate', '4');
incidentReq.update();
}
}
}
})(current, previous);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-22-2024 06:38 AM - edited 02-22-2024 06:41 AM
Hello @Talari Balateja -
Please create Before Update BR on sn_si_incident table and remove the CONDITION IS STATE CHANGES TO CLOSED COMPLTE
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-22-2024 06:47 AM
This will still not work, the ask is that when the task is closed, the parent state should change to work in progress
The portion of script below will query the whgole sn_si_task table and not just created for that parent
var newTasks = new GlideRecord("sn_si_task");
newTasks.addEncodedQuery('state', 'Closed Complete');
newTasks.query();
var flag = false;
while (newTasks.next()) {
if (current.state != '3') {
flag = true;
}
And then