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.

Assign subsequent tasks to the same person who was assigned to the previous task

Cat
Mega Guru

Hi All,

 

I hope you can help.

 

I have a request item that creates a task. It is mandatory that the task is assigned to a person before it is closed. I want any other tasks created on that RITM to have the same assignee as was on the closed task. 

I only want this to occur in one catalog item only, so I cannot make any sweeping changes. I'm hoping to do this via workflow, or Catalog UI Policy or client script.

 

Any help would be appreciated 16:33

 

Cat

6 REPLIES 6

James Chun
Kilo Patron

Hey @Cat,

 

I think you can use an Assignment Rule for this. It should work unless you are assigning the assignee through other capabilities such as a workflow.

 

  • Navigate to Routing and Assignment > Assignment Rule
  • Create a new record with the following:

JamesChun_0-1711049964574.png

Use your catalog item here instead.

 

The script will be something like:

//Find if there are previously closed tasks under same RITM
var scTaskGr = new GlideRecord('sc_task');
scTaskGr.addEncodedQuery('request_item=' + current.getValue('request_item') + 'active=false^assigned_to!=NULL');
scTaskGr.orderByDesc('sys_created_on');
scTaskGr.setLimit(1);
if (scTaskGr.next()) {
    current.assigned_to = scTaskGr.getValue('assigned_to');
}

 

Hope it helps, cheers

This looks like you may be onto something! Let me quickly give this a go, and I'll report back!

Unfortunately that didn't work for me. Thanks for giving it a go though!

No worries, do you mind sharing how you are creating these tasks?

And when you say it didn't work, was it because the 'assigned to' field was blank or assigned with someone else?