how to fetch value of owned by in business capability field on demand table

archie5
Tera Expert

On the Demand table, I need to find the value of Business Capability's owned by person. Note that Business capability is a glide list, so I need to fetch the first value in the glide list and then fetch the owned by from there.

So far, I have got this - 

var asmtqr = new GlideRecord('dmn_demand');
asmtqr.addQuery('sys_id', 'e621d2aa47b47550578a8147536d43ca');
asmtqr.query();
if (asmtqr.next()) {
var bc = asmtqr.business_capabilities;
gs.print('bc: ' + bc);
var owner = bc.owned_by;
gs.print('owner: ' + owner);
}

bc is printing the sys id of the business capability but owned by is coming as undefined. Can you help? 

1 REPLY 1

Rohit01998
Tera Guru

Hello @archie5 ,

try this script...

var asmtqr = new GlideRecord('dmn_demand');
asmtqr.addQuery('sys_id','e621d2aa47b47550578a8147536d43ca');
asmtqr.query();
if(asmtqr.next()) {
var bc = asmtqr.business_capabilities.getDisplayValue().split(",");

var firstValue = bc[0];

gs.log("firstValue"+ bc[0]);

var support = new GlideRecord('table_name_of_business_capabilities'); //Enter table name of List field
support.addQuery('name',firstValue);  //if you have different field in LIST field then change 'name' with your field

support.query();
if(support.next()) {
var owner = support.owned_by   //If 'owned_by' is reference type then add '.getDisplayValue()' next to it

gs.log("2nd Value"+ owner);
}
}

 

Help others to find a correct solution by marking the appropriate response as correct answer and helpful.