How to reference current task fields from the Catalog Task workflow activity?

Nick Peters
Tera Guru

Hello everyone,

I am using the Advanced script field on the Catalog Task workflow activity in order to create some custom text in the Description field of the current task. In particular, there are 4 fields/variables we would like to include - 2 variables from the current Catalog Item; the current task's number; and the current task's "Opened by" field (which is a reference to the sys_user table). I can get the Catalog Item Variables to appear but not the fields from the current Catalog Task.

Here is my code from the Advanced script of the Catalog Task where I am defining these values:

var emp = current.variables.employee_id + ', ';

var ldw = current.variables.last_day_worked + ', ';

var num = task.number + ', ';

var openedBy = task.opened_by.user_name;

What is the proper syntax for defining values from the current task? I have also tried:

  • current.task.####
  • current.sc_task.####

Again, the first 2 lines are generating values - lines 3 and 4 are not.

1 ACCEPTED SOLUTION

dvp
Mega Sage
Mega Sage

Other   way you can do is once task is created use run script and query the task and update the description field with the task values


View solution in original post

5 REPLIES 5

Steven1
Tera Expert

Try.



current.number


current.opened_by.user_name


Steven,



Thank you for your reply. I have tried that but unfortunately, current references the current Requested Item record, not the current Catalog Task record. By using current.number, I get the Requested Item number instead of the Catalog Task number.


dvp
Mega Sage
Mega Sage

Other   way you can do is once task is created use run script and query the task and update the description field with the task values


Your reply got me thinking... I'm not positive, but I believe that the Advanced script field in the Catalog Task workflow activity is executed before the task is created. Therefore, you would not be able to use this script to get values from the current task, you could only set values.



If this is the case, I think I can use your recommendation of doing this via a Run Script activity in the workflow.



Thank you!