cancel
Showing results for 
Search instead for 
Did you mean: 

How to use forEach in Design Studio

0 Kudos

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

Accepted Solutions (1)

Accepted Solutions (1)

Former Member

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.

Answers (1)

Answers (1)

0 Kudos

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