- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-18-2018 12:08 PM
Hello -
I am using Advanced Script within a Catalog Task activity for a Service Catalog Item. I am trying to set the Short Description to contain the User ID (user_name field from sys_user) from the Requested For variable that was populated on the Request Item.
If I do this with the following code, I get the 'name' value, which is set as the Display Value for the sys_user reference field. However, I need to get the user_name value displayed instead:
task.short_description = current.variable_pool.requested_for.getDisplayValue();
I am curious if I am able to do a GlideRecord query within the Advanced Script of the Catalog Task activity, and if so, what the code would be to get the user_name value. I tried some variances of code that I found from researching this issue, but I am not having any luck:
var userid = current.variable_pool.requested_for;
var gr = new GlideRecord('sys_user');
gr.addQuery('user_name', userid);
gr.query();
if(gr.next()) {
var userName = gr.name;
}
task.short_description = userName;
Thanks in advance!!
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-18-2018 12:15 PM
do something like below; you don't need to query reference field, you can dot walk it.
task.short_description = current.variable_pool.requested_for.user_name;

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-18-2018 12:15 PM
do something like below; you don't need to query reference field, you can dot walk it.
task.short_description = current.variable_pool.requested_for.user_name;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-18-2018 12:20 PM
Wow, wish I would have posted this an hour ago! Thanks Mike!