Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Requested Item - How do I reference info from item in to task

Greybed
Kilo Explorer

Hi,

I need information to be pulled from a Requested Item in to a Catalog task to populate in Short Description. The fields I need the information to be pulled from are ${location.company.name} and ${cat_item.name}, when I have tested them they are not bringing up any of the information.

I have attached a screenshot of what it looks like, need it to pull info from user record for location and the type of item that has been requested from the catalog item.

Hope this makes sense.

Any help is greatly appreciated.

Thank you

11 REPLIES 11

Jim Coyne
Kilo Patron

Can you post a screenshot of the Catalog Task activity you have setup to create the task? Is the Location field on the Requested Item being populated? Or is it a catalog item variable?


Greybed
Kilo Explorer

I have posted a screenshot.

The location is part of the user record so on the requested item it autopopulates on the top half of the screen with the users details.


Jim Coyne
Kilo Patron

You need to remove the "//" at the beginning of the



task.short_description = current.location.company.name + " " + current.cat_item.name

line. The "//" is used to "comment out" the line of code so that it does not actually run.


Greybed
Kilo Explorer

Wow thank you Jim that has partly worked...it is now bringing the item up in the Short Description but not the location?

In the User Record it is just 'Location' so I amended the script you gave me but still no joy. Sorry I am not very good with scripts and appreciate ALL the help you have given me


Jim Coyne
Kilo Patron

Try:



task.short_description = current.request.requested_for.location.company.name + " " + current.cat_item.name


I'm not 100% sure because I do not know which user record you are displaying at the top of your form, but I think the Request's Requested for user is a good guess 🙂