Unable to display value from model category in my script

adminion
Tera Contributor

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;

2 REPLIES 2

Danish Bhairag2
Tera Sage
Tera Sage

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

 

 

AshishKM
Kilo Patron
Kilo Patron

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