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

Sorry for the lack of disclaimer. My code is untested. Can you send me the error (or warning) log message that is complaining about the syntax, or a screenshot if I've made a grotesque syntax error that is prrventing you from saving? I don't see it here.


Hi Chuck, the error message is saying 'unrecoverable syntax error.'



find_real_file.png


That's odd. I was able to copy and paste the script directly from this post in to a business rule on the Req Item table and it was fine.



find_real_file.png


I fixed it. Somehow there was an extra bracket and function section in the code. I will test it and get back to you! Thanks again.


P.S. Bobbie Singh (Sukhwinder) says hi! You were her teacher in the Service Now course