Set task.assigned_to

Troy S_
Kilo Expert

I have a workflow on the sc_req_item table.   I would like a task to be assigned to the person who opened the ticket.   Here is my scenario

  1. Have several catalog tasks Task A, Task B, Task C
    1. Task A is completed goes to Task B
    2. Task B is completed--Task C is then created automatically when Task B is completed, It shows the opened by of Task C to be the person who closed Task B
  2. I would like to automatically assign the ticket to the person who created the ticket
  3. This is What I have tried
    • task.assigned_to = current.opened_by;
      • However that set the value to the person who made the original request (Loren Smith) and not the individual (Kirk Smith) who closed the previous step.

 

 

      • When I look at the Activity for the Task it states the following:

        • 03/04/2014 10:19 AM   Kirk Smith - Changed:   Assigned to, Impact, Opened by, Priority

        • Assigned to: Loren Smith

        • Impact: 3 - Low

        • Opened by: Kirk Smith

        • Priority: 4 - Low

      • So how do I get to read the correct Opened by:   so it Assigns the ticket to Kirk Smith.

 

 

    • I have also tried:

      • task.assigned_to = sc_task.opened_by;

      • task.assigned_to = task.opened_by;

      • Both of these commands do populate the Assigned To field.

1 ACCEPTED SOLUTION

eican
Kilo Guru

Try:


task.assigned_to = gs.getUserID();


View solution in original post

3 REPLIES 3

eican
Kilo Guru

Try:


task.assigned_to = gs.getUserID();


Troy S_
Kilo Expert

That seemed to work thank you.


that should work for you since the tasks are sequential... but what to do when they are NOT sequential... say you want task 3 assigned to whoever completed task 1?



Glad you asked... hehehe



creae a field on task called task_id that contains the original short description of the task <this is a good idea no matter what>



then you can modify the following script to assign the task to someone that closed any other task in the workflow based on the task_id <we use it to set the assignment group>....



assigntask();


function assigntask()


{


var taskid= "Configure workstation";


var task1 = new GlideRecord("sc_task");


task1.addQuery("parent", current.sys_id);


task1.addQuery("u_task_id","CONTAINS",taskid);


task1.query();


if (task1.next()) {


task.assignment_group = task1.assignment_group;