Need to get variable values in task short description

Ashwini8
Tera Contributor

Hi All, We have a catalog item created and after submitted it will go for 2 levels of approval and once the approval is done it will create a task in the task the short description is mandatory field and in short description we need to get the catalog item name: requstedfor : user ID. we need this details in short description field. How to get these details please suggest.

 

 

1 ACCEPTED SOLUTION

Voona Rohila
Kilo Patron
Kilo Patron

Hi Ashwini

In your catalog task activity , use below code in script section.

var desc;

desc += "Item Name :"+current.cat_item.name;

desc += "Requested For :"+current.request.requested_for.getDisplayValue();

desc += "Requested For :"+current.request.requested_for.user_name;

task.short_description =desc;

 


Mark it helpful if this helps you to understand. Accept solution if this give you the answer you're looking for
Kind Regards,
Rohila V
2022-25 ServiceNow Community MVP

View solution in original post

9 REPLIES 9

Can you share few screenshots.


Mark it helpful if this helps you to understand. Accept solution if this give you the answer you're looking for
Kind Regards,
Rohila V
2022-25 ServiceNow Community MVP

find_real_file.png

If you need it as default value then copy the sys_id of that record and use it as default value.

find_real_file.png

find_real_file.png


Mark it helpful if this helps you to understand. Accept solution if this give you the answer you're looking for
Kind Regards,
Rohila V
2022-25 ServiceNow Community MVP

Vinayak Belgaon
Mega Guru
Mega Guru

Within the task activity of the workflow, you have the option to add script as an advance step. You can set the values of all the task field.
task.short_description =current.variables.variablename;

 

Regards

Vinayak

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

general syntax to access any variable within catalog item workflow is this

current.variables.<variableName>

If that is reference variable then ensure you use getDisplayValue() to get the name and not sys_id

var variableValue = current.variables.<variableName>.getDisplayValue();

Regards
Ankur

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