This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

DEVELOPERS FORUM - Need help with labels of lists

CycleOp - Monday, July 4, 2011 3:10 PM:

Hi,

I am looking for a piece of code that – given an Item, and the name of one of its properties (like ‘buy_make’) returns the name of the list (of ItemType = ‘List’).
so for example – for (ItemType = ‘Part’ ) and (property = ‘make_buy’) returns the name of the list (‘make buy’).
Alternatively – I am looking to get the “Label” of a list item, instead of its value. For example : The values in make/buy list are: ‘M’ & ‘B’, and the labels are ‘Make’ & ‘Buy’.

Thanks for the help.
Sagi


Brian - Wednesday, July 6, 2011 5:14 AM:

Hi Sagi,

This should do it:

var inn = this.getInnovator();
var propertyName = "make_buy";
var thisItemType = "Part";
var listNam = getListName(propertyName, thisItemType);

function getListName(propertyName, thisItemType){
var propAML1 = "<Item type="Property" action="get" select="data_type,data_source">";
propAML1 += "<source_id><Item type="ItemType" action="get"><name>";
propAML1 += thisItemType;
propAML1 += "</name></Item></source_id>";
propAML1 += "<name>";
propAML1 += propertyName;
propAML1 += "</name></Item>";

var propRel1 = inn.newItem();
propRel1.loadAML(propAML1);
propRel1 = propRel1.apply();

return propRel1.getProperty("data_source","");
}

Hope this helps,

Brian.