Trying to Pull the TASK Number on a Create Task Activity in a Workflow

John Bone
Giga Expert

I have a reference variable on a catalog item called Project Reference Number: (u_project_reference_number) that is referencing the sc_task table. After looking at other Community posts, I am trying to pull the TASK number and populate it in this field on the Create Task activity in the catalog item's workflow using the script below, but it isn't working for me. This is the only line of code in the Advanced script section on this Create Task activity. Does what I need to do get this working?

workflow.scratchpad.u_project reference_number = task.number;

 

Thank you for your help!

1 ACCEPTED SOLUTION

Hello @Ankur Bawiskar

 

I appreciate the help, but it didn't work for me. Instead of pulling the TASK number and putting it into a variable on the catalog item workflow, the particular catalog item that I'm working with involves passing information over to another system by using a UI Action on the TASK that gets created by the workflow. Since the UI Action is on the TASK table, I was able to use current.number in the UI Action script to pass the TASK number to the other system.

 

Thank you very much,

Will Bone

View solution in original post

7 REPLIES 7

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

do this

task.myField = current.variables.u_project_reference_number.number; // give correct field where you want to set

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

Hello @Ankur Bawiskar

Thanks for your response!   Unfortunately, the field is still blank: 

find_real_file.png

I put the script below into my workflow as you suggested: 

find_real_file.png

Any suggestions?

 

Thank you!

Hi,

the number field on task is auto-generated.

Why you wish to set it from script?

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

Hello @Ankur Bawiskar!

I am trying to get the TASK number so that I can pass the value to another system, so that the other system can use the TASK number to pass back a value of "Closed Complete" when the automation activities performed by the other system are successfully completed. 

Thank you for your help!