Unable to display value from model category in my script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-14-2023 10:08 AM
Hi SN Community 🙂
Using a Run Script in a Workflow I am trying to get the module category values of 'laptop' and 'desktop' displayed on the following script.
Currently it only returns the sys id from the model category.
I'd like to return the values of 'laptop' and 'desktop' of the model category - How do I do this?
(function() {
//var answer = [];
var list = current.variables.DW_hardware_users_assets.toString();
var listArr = list.split(',');
for (var i=0;i<listArr.length;++i) {
var asset = new GlideRecord('alm_asset');
asset.addQuery('sys_id',listArr[i]);
asset.query();
if(asset.next()){
var cat = asset.model_category;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-14-2023 10:19 AM - edited 11-14-2023 10:21 AM
Hi @adminion ,
You can try adding .getDisplayValue() as shown below. That will return u the display name.
var cat = asset.model_category.getDisplayValue();
Thanks,
Danish
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-14-2023 10:23 AM - edited 11-14-2023 10:24 AM
Hi @adminion ,
asset.model_category is returning the sys_id of model_category record because it is reference field in alm_asset table. Use getDisplayValue() method for model category name. Try it and share the result.
if(asset.next()){
var cat = asset.model_category.getDisplayValue();
-Thanks
AshishKMishra
Please mark this response as correct and helpful if it helps you can mark more that one reply as accepted solution