How to assign the 'Approval - User' task to to another tasks assigned to

Mario25
Giga Expert

Hi,

I have a workflow that currently sends an approval to a group after a task gets completed.  How do I get that approval task to be assigned to only the tech assigned to that 1st task instead of the group?  I've looked at whats available in the select fields list under 'users' but wasn't able to find what I wanted because the 'assigned to' is pulling from the RITM and not the previous task in the workflow. 

find_real_file.png

I feel I'll have to use the advanced script option.

Workflow shown here:

find_real_file.png

1 ACCEPTED SOLUTION

randrews
Tera Guru

ok the first thing you want to do is grab the sys id for the task you are going to want to grab the approver from.. so in the 1'st task put the following in the advanced script box..

 

workflow.scratchpad.approvalID = task.sys_id;

 

now in the approval we need to grab that task by the sid.. and get the approval id.

 

so in the approval script you will use

tsk = new GlideRecord('sc_task');

tsk.get(workflow.scratchpad.approvalID);

 

 

now in your actual function to push ids... just push the tsk.assigned_to.sys_id.

 

View solution in original post

4 REPLIES 4

sachin_namjoshi
Kilo Patron
Kilo Patron

You will have to use scratchpad to pass assigned to between two workflow activities and then use advanced script to assign task to use from stored scratchpad variable value.

 

Check below for workflow scratchpad

 

https://docs.servicenow.com/bundle/helsinki-servicenow-platform/page/administer/using-workflows/concept/c_WorkflowScratchpadVariables.html

 

Regards,

Sachin

randrews
Tera Guru

ok the first thing you want to do is grab the sys id for the task you are going to want to grab the approver from.. so in the 1'st task put the following in the advanced script box..

 

workflow.scratchpad.approvalID = task.sys_id;

 

now in the approval we need to grab that task by the sid.. and get the approval id.

 

so in the approval script you will use

tsk = new GlideRecord('sc_task');

tsk.get(workflow.scratchpad.approvalID);

 

 

now in your actual function to push ids... just push the tsk.assigned_to.sys_id.

 

Adding to the end of this advanced script in the approval tasks will push what was taken from the task you put (workflow.scratchpad.approvalID = task.sys_id) on.

find_real_file.png

 

to make it clear for anyone else in future
marking this answer as the correct one


thank you @randrews & @sachin.namjoshi

Aniko Hegedus1
Giga Contributor

Hi,

 

The "assigned to" is pulled from the table your workflow is running on

find_real_file.png

 

I think on the Approval Activity you'll have to click "advanced" add the approvers by script:

find_real_file.png