How do I get a Workflow Catalog Task to pull the Requested Item into the short description?

apassey
Kilo Explorer

I feel like my coworker and I have tried every script we can possibly think of!!
We are using the Advanced Script in a Workflow Catalog Task to try to pull the Requested Item into the Short Description of the task.

 

For example, If I were to go into Service Catalog and select Hardware (Category), then Select and order a Laptop (Item), I would like the tasks created by the workflow to contain "Hardware Request Validation - Laptop" in the Short Description field.
find_real_file.png

 

We've tried using:

task.short_description = "Hardware Request Validation - " + current.request.requested_item     and we have tried using multiple varieties of this script line including replacing .requested_item with sc_req_item and sc_cat_item along with adding .name to the end of the string to, but to no avail, it just keeps coming in as - undefined.

 

Any help on this is much appreciated!!

 

Thank you!

1 ACCEPTED SOLUTION

jfarrer
Mega Guru

If you're trying to get the name of the Catalog item then you should use:


task.short_description = "Hardware Request Validation - " + current.cat_item.name;



task refers to the catalog task that is being created. current refers to the requested item. current.cat_item is the catalog item (i.e. form that they just filled out).



If you are instead looking for the requested items short description or something like that you can just use current.short_description.


View solution in original post

4 REPLIES 4

jfarrer
Mega Guru

If you're trying to get the name of the Catalog item then you should use:


task.short_description = "Hardware Request Validation - " + current.cat_item.name;



task refers to the catalog task that is being created. current refers to the requested item. current.cat_item is the catalog item (i.e. form that they just filled out).



If you are instead looking for the requested items short description or something like that you can just use current.short_description.


Great minds think alike James Farrer


Your script was bang on!!!


Using: task.short_description = "Hardware Request Validation - " + current.cat_item.name;     worked!!
When I tried it almost exactly the same except with current.sc_cat_item.name, it would state "undefined", but your script suggestion worked!!! Thank you so much!! It felt like we had tried every variation we could think of!


Jim Coyne
Kilo Patron

This should do the trick:



task.short_description = "Hardware Request Validation - " + current.sc_cat_item.name;



"current" refers to the sc_req_item table you are running the Workflow on and "sc_cat_item" points back to the catalog item that was ordered, and "name" is of course the name of the catalog item.