Skip to Content

How to use forEach in Design Studio

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)
Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

2 Answers

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

    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.

    Add comment
    10|10000 characters needed characters exceeded

  • Mar 31, 2017 at 11:33 AM

    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

    Add comment
    10|10000 characters needed characters exceeded