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

I would use a display business rule on the Task (sc_task) table. It's kind of like an onLoad client script, but has better access to related database objects.



Check the Advanced checkbox.


When: display



Something like this:



if (current.request_item && current.isNewRecord()) {


        if (current.request_item.assigned_to && current.assigned_to == '') {


                  current.assigned_to = current.request_item.assigned_to;


        }


}



It checks if there is a parent request item and this is a new record, then checks to see if the RITM assigned to field has a value and the task is blank. Then and only then does it populate the task assigned to with the RITM assigned to.


Hi Chuck, thank you for the script. Due to some conflicts with our own settings it did not work. otherwise the script is fine. I talked to my lead and we were able to use the business rule below to populate the task resource with the resource listed on the ritm. However, the name of the resource is not populating within the task description on the bottom of the ritm screen (as shown below). Do you know how to fix this? Thank you again for all of your help!!



find_real_file.png


find_real_file.png


find_real_file.png


Excellent work using a scriptless solution!



Q: Are you certain the parent request item has a resource to copy from?


Yes it does. When I input the resource into the ritm, I save it before scrolling down to the tasks. The name just isn't showing up on that field, but when I go into the task, it is there.


I've seen this before, but cannot find where it was. Initially it looks like an ACL issue, but since you can see the value when you go in to the record, that doesn't appear to be it. I'll keep digging and let you know what I find. Hopefully someone else can find it too.