$(function () { pageContext.i18n.modTalk = 'moderation talk'; pageContext.i18n.replyToComment = 'Reply'; pageContext.i18n.modTalkEmpty = 'moderation talk is empty'; pageContext.url.getModTalk = "/comments/%25ID%25/listModTalk.json"; pageContext.url.possibleCommentRecipients = "/comments/%ID%/possibleRecipients.json"; pageContext.url.commentEdit = '/comments/%25ID%25/edit.html'; pageContext.url.commentView = '/comments/%ID%/view.html'; pageContext.i18n.commentVisibility = { 'full': 'Viewable by all users', 'op': 'Viewable by the original poster', 'mod': 'Viewable by moderators', 'opAndMod': 'Viewable by moderators and the original poster', 'other': 'Advanced visibility', 'dialogTitle': 'Comment visibility', 'selectGroups': 'Visible to groups', 'selectOther': 'Other recipients', 'selectOriginalPoster': 'Original poster', 'selectModerators': 'Moderators', 'selectAssignees': 'Asked to answer users' }; pageContext.i18n.commentMenuLabels = { 'comment-edit': 'comments.menu.edit', 'comment-delete': 'comments.menu.delete', 'comment-convert': 'comments.menu.convert' };pageContext.i18n.answer= { bestAnswer: 'Best Answer', controlBar : { accept: 'Accept', unaccept: 'Unaccept', acceptCommand: 'Accept this answer as correct', cancelAcceptedCommand: 'Remove this answers accepted status' } }; window.croles = { u: false, op: false, m: false, og: false, as: false, ag: false, dc: false, doc: false, eo: false, ea: false }; tools.init({ q: { e: false, ew: false, eo: false, r: false, ro: false, d: false, dow: false, fv: false, c: false, co: false, p: false, tm: false , ms: false, mos: false }, n: { f: false, vf: false, vfo: false, vr: false, vro: false, c: false, co: false, vu: false, vd: false, w: false, wo: false, l: false }, c: { e: false, eo: false, d: false, dow: false, ta: false, tao: false, l: false }, a: { e: false, ew: false, eo: false, d: false, dow: false, a: false, aoq: false, ao: false, tc: false, tco: false, p: false, tm: false }, pc: croles }, { tc: true, nsc: true }); commandUtils.initializeLabels(); }); Skip to Content
0

Read Attribute value of a member selected in a dropdown

Mar 30, 2017 at 08:19 AM

79

avatar image
Former Member

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

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

2 Answers

avatar image
Former Member Mar 30, 2017 at 11:28 AM
0

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:


zmjg5.png (6.8 kB)
Share
10 |10000 characters needed characters left characters exceeded
avatar image
Former Member Mar 30, 2017 at 12:38 PM
0

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

Show 1 Share
10 |10000 characters needed characters left characters exceeded
Former Member

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

A.

1