- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-22-2022 08:53 PM
we have the OOB workflow that creates two change tasks when state of change is set to implement.
When the "change" state moves from implement to review or close state, the change task should be assigned to the person who created the change request (requester) and another change task should be assigned to user (say Person A). How to achieve this?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-22-2022 09:48 PM
Hi,
You can write before update business rule where you can mention the condition as State changes to Review or State changes to Closed Complete.
In the script you can write below code:
var taskGR = new GlideRecord('change_task');
taskGR.addQuery('change_request',current.sys_id);
taskGR.query();
if(taskGR.next()){
taskGR.assigned_to= <user A>;
taskGR.update();
}
current.assigned_to = current.requested_by;
Please mark correct if helpful.
Regards,
Vaibhav Dane
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-22-2022 09:46 PM
Ideally you should close the change request (Parent) when all the change tasks are closed.
Thanks & Regards,
Vasanth
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-22-2022 09:48 PM
Hi,
You can write before update business rule where you can mention the condition as State changes to Review or State changes to Closed Complete.
In the script you can write below code:
var taskGR = new GlideRecord('change_task');
taskGR.addQuery('change_request',current.sys_id);
taskGR.query();
if(taskGR.next()){
taskGR.assigned_to= <user A>;
taskGR.update();
}
current.assigned_to = current.requested_by;
Please mark correct if helpful.
Regards,
Vaibhav Dane
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-22-2022 10:39 PM
Hi
Thanks for the reply!
I tried the following but it didn't work. (Requirement is that when parent change state is changed to review or closed, the change task which is of type implementation should be assigned to the Person who requested the change (parent).
BR on change request table:
advanced:
(function executeRule(current, previous /*null when async*/ ) {
// Add your code here
var taskGR = new GlideRecord('change_task');
taskGR.addQuery('change_request', current.sys_id);
taskGR.addQuery('change_task_type', 'implementation');
taskGR.query();
if (taskGR.next()) {
taskGR.assigned_to = current.requested_by;
taskGR.update();
}
// current.assigned_to = current.requested_by;
})(current, previous);
similarly, when change task type is testing, it will have to be watched by "Person A" when parent change state is set to review or closed. Please help me correct this code as per the requirement.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-22-2022 10:45 PM
Change it to 'After' Business rule instead of before.
Regards,
Musab