$(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

How to use forEach in Design Studio

Mar 30, 2017 at 10:47 AM

648

avatar image

Hi,

I'm new to Design Studio and am trying to use forEach to loop through an array. Every time, forEach is highlighted by Design Studio - "Couldn't resolve reference to member 'forEach'".

I'd greatly appreciate any help on how to use this correctly.

Thanks,
David

foreach.png (16.8 kB)
10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

2 Answers

Best Answer
avatar image
Former Member Mar 30, 2017 at 10:58 AM
0

David,

It's actually not that difficult once you get your head round it...

I think getMembers() is the way to do it, not the getMemberList().

Here's a simple example retrieving 10 members of 0CUSTOMER dimension and displaying their internalKeys on screen:

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

myArray.forEach(function(element, index) {

APPLICATION.alert(element.internalKey);

});

You basically only refer to "element" to retrieve its properties such as text, internal key or external key, while looping through individual members of the dimension.

Share
10 |10000 characters needed characters left characters exceeded
David Lee Mar 31, 2017 at 11:33 AM
0

Hi Agata,

Thanks for your quick and helpful response.

Changing from getMemberList() to getMembers() solved my problem. Seems obvious now, as getMemberList() will return a list and not an array.

Best,
David

Share
10 |10000 characters needed characters left characters exceeded