Assign task back to requestor when Parent change ticket state is changed to review

Demo24
Tera Expert

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?

1 ACCEPTED SOLUTION

Vaibhav Dane
Tera Expert
Tera Expert

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

View solution in original post

7 REPLIES 7

Vasantharajan N
Giga Sage
Giga Sage

Ideally you should close the change request (Parent) when all the change tasks are closed. 


Thanks & Regards,
Vasanth

Vaibhav Dane
Tera Expert
Tera Expert

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

Hi @Vaibhav Dane 

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:

find_real_file.png

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.

Change it to 'After' Business rule instead of before.

Please hit like and mark my response as correct if that helps
Regards,
Musab