cancel
Showing results for 
Search instead for 
Did you mean: 

Read Attribute value of a member selected in a dropdown

Former Member
0 Kudos

Hi,

I would like to read the "country" attribute value of a company member selected in a dropdown. I tried the following script without success :

var cc = DROPDOWN_CC.getSelectedValue(); //company code selected DS_1.getMembers("COMP_CODE", 99).forEach(function(element, index) { element.getAttributeMember("COUNTRY");

if (element==cc) {

APPLICATION.alert(element.text);}

});

thanks for your help

Mat

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi Agata

thanks for your help. It worked for me. The internalkey was the solution I guess. My dropdown has a target bound to DS_1 which means that DS_1 has always one value. May be that is the reason why it worked for me

thanks again

Mat

Former Member

Thanks Mat, good to know the attribute works if you filter your data source to just one member.

A.

Former Member
0 Kudos

Mat,

I have tried this, and unfortunately, it doesn't seem like DS is reading the attributes correctly - it retrieves ("All_members") instead.

Also, I don't think element === cc is doing the right thing. cc will be returned as a value, element has its internalKey, externalKey, as well as text etc. These two have to match. So, it seems they only match if you do element.internalKey == cc.

The below code displays the matching element, selected country, and its attribute:

var cc = DROPDOWN_1.getSelectedValue();

var myArray = DS_1.getMembers("0CUSTOMER", 99);

var country = "";

myArray.forEach(function(element, index) {

if(element.internalKey == cc) {

country = element.getAttributeMember("OCOUNTRY").internalKey;

APPLICATION.alert(element.internalKey + " " + cc + " " + country);

}

});

You will notice that the code works, selecting the right member in the if statement, but the attribute is incorrect: