- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-24-2018 12:08 PM
Hi Everyone,
I've got some variable sets used in Service Catalog items that have a title on them. For example, a variable set for requesting a computer. The variable set has a title of "Computer Hardware".
How can I access that in a mail script to show in a notification? I guessed (incorrectly) to use getTitle(). Is this possible?
Thanks!
Chris Schuh
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-24-2018 01:32 PM
Unfortunately there isn't an API to get the variable set container details. When a catalog item is ordered, the code loops through all the associated item variables and creates "instances" of each one linked to the task. Details on knowing it was originally part of a variable set are unknown at that level.
In the out of the box mail script code you will see functions like getLabel() and getDisplayValue(), there is also getId() which is the SysID of the variable that is linked to the catalog item/variable set. You could use this SysID and do a lookup to get the Variable Set name. This could be "expensive" in your notifications emails though depending on how many variables you have as it will be performing the query over and over again.
var variableRec = new GlideRecord("item_option_new");
variableRec.get(vs.get(i).getId());
template.print(variableRec.cat_item.getDisplayValue());
or
template.print(variableRec.variable_set.getDisplayValue());
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-24-2018 01:32 PM
Unfortunately there isn't an API to get the variable set container details. When a catalog item is ordered, the code loops through all the associated item variables and creates "instances" of each one linked to the task. Details on knowing it was originally part of a variable set are unknown at that level.
In the out of the box mail script code you will see functions like getLabel() and getDisplayValue(), there is also getId() which is the SysID of the variable that is linked to the catalog item/variable set. You could use this SysID and do a lookup to get the Variable Set name. This could be "expensive" in your notifications emails though depending on how many variables you have as it will be performing the query over and over again.
var variableRec = new GlideRecord("item_option_new");
variableRec.get(vs.get(i).getId());
template.print(variableRec.cat_item.getDisplayValue());
or
template.print(variableRec.variable_set.getDisplayValue());
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-24-2018 01:52 PM
Thank you so much - it is greatly appreciated. I'll have to weigh the cost of running it and see if it has a huge impact on performance, as we do intend use it in a loop.