Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Is there a way to automatically reassign tasks when the request is assigned to a different resource group?

zabrina
Mega Expert

If not, is there some sort of workaround like creating mandatory fields or notifications reminding the transferring group to change the resource group on tasks? Any suggestions would be helpful.

1 ACCEPTED SOLUTION

Chuck Tomasi
Tera Patron

I'm going to make the following assumptions. Please correct me if I'm wrong.


  • You are reassigning a request item by changing the assignment group
  • You want to reassign any active/open tasks (and leave completed ones alone.)


It would be done with an AFTER business rule something like this:



Name: Reassign active tasks


Table: Requested Item (sc_req_item)


When: After


Insert: true


Update: true


Advanced: true


Condition: Assignment group | changes


Script:


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


        var task = new GlideRecord('sc_task');


        task.addQuery('request_item', current.getValue('sys_id'));


        task.addQuery('active', true);


        task.query();



        while (task.next()) {


                  task.assignment_group = current.assignment_group;


                  task.update();


        }


})(current, previous);


View solution in original post

19 REPLIES 19

Thanks for passing on the message.



Is there anything more I can help with to get your business rule running or has it been resolved?


Hi Chuck, the script works fine. However, I had one last question. How can I edit the script so that it only applies to one group instead of being a global change? I wanted it specifically for EDSS.


You can add another line before the task.query() line.



Something like this:



task.addQuery('assignment_group', 'SYS_ID'); // change SYS_ID to the actual sys_id of the EDSS group.



To get the sys_id, go to the list of groups, right click on the EDSS group name and select Copy sys_id then paste it in the script where indicated above and it will add that filter to the tasks.



find_real_file.png


Thank you!! Your answer was very thorough


Hi Chuck, I apologize but I did not make my question clear enough. I am hoping you can answer one last request- when a RITM is assigned to a fulfiller, how can I make the tasks automatically be assigned to that person as well? The fulfiller should be able to reassign one of the tasks to other people if they wish, and not have it default back to them.