Skip to Content

Loop List using API Methods

Hi All,

My Bex Query Structure(With No KF'S) :

                                  

PRODUCTS ID         PRODUCTS NAME           Words1                 Words2

  1                            wax                                  asdsad                  wrffvbv

  2                            lighter                               sadadas                rgergbg

  3                            candle                              asdasds                wvvxdsd

In DS 1.3, i am stuck up in the below steps itself.

var arr_products = DS_1.getMembers("PRODUCTS", 30);   

var arr_words1 = DS_1.getMembers("Words1", 30);

var arr_words 2 = DS_1.getMembers("Words2", 30);

I got the values to get stored in array from above.

I am trying to achieve like below. Get the list in an array and loop over that array and concatenate the text values .

Expected Output like below in ListBox when selection of wax and lighter in product dimension filter :

wax

asdsadwrffvbv   < - Concatenate both words and show as one word

lighter                          

sadadasrgergbg   < - Concatenate both words and show as one word    

Hope it should be understandable for everyone and need your solution guys.

Thanks,

Dinya. 

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Best Answer
    avatar image
    Former Member
    Dec 23, 2014 at 05:23 AM

    Hi Dinya,

    Try using the following script in your Dimension Filter.

    var arr_words1=DS_1.getMembers("Words1", 30);

    arr_words1.forEach(function(element1, index)

    {

     

      DS_1.setFilter("Words2", element1.internalKey);

      var arr_words2=DS_1.getMembers("Words2", 30);

      arr_words2.forEach(function(element, index)

         {

            LISTBOX_1.addItem(element1.internalKey+ " " +element.internalKey, element1.text+" " +element.text);

           });

    });

    Let me know if this works.

    Regards,

    Anuraag

    Add comment
    10|10000 characters needed characters exceeded

    • Anuraag,

        Thanks but there are two levels of dimension filter One is Company Code represented in the form of KF's which has UID in Drop Down and other is Product Dimension Filter.

      I tried the above script for dimension filter like you mentioned..

      The words got concatenated on applying Product Dimension Filter but there is one more level above is Company Code Drop down. So the scenario is first iam choosing an KF in Company code and then applying ALL/multiple selection item in Product dimension filter where then these words has to be concatenated. Currently the words gets concatenated based on Product Dimension filter, but it has to do starting from drop down company code ALL/single selection and then this dimension filter application after then words should get concatnated

      Filter Panel Input:

      Company Code Drop down

      Product Dimension filter

      Load Button

      ListBox Output on selection of above filters:

      wax

      asdsadwrffvbv  

      lighter                          

      sadadasrgergbg 

  • Dec 30, 2014 at 06:00 PM

    Dear All&Anuraag,

    Tried to build an requirement in DS 1.3.

    1)  I have one dimension filter named Product in my filter Panel and output display component as ListBox.

    2) Tried to get to display like below in List Box which is my output to achieve:

    Product 1

      Word1Word2

    Product 2

      Word3Word4

    3) First i selected an Product 1, Product 2 from Product dimensional Filter, so ListBox Displayed like below based on the selected product after writing an script on Apply Product Dimension Filter.

    Product 1

    Product 2

    4) Now i tried to display Concatenated Word for selected Products. So written an script like anurag mentioned in Product On Apply Dimension Filter:

    var arr_words1=DS_1.getMembers("Words1", 30);

    arr_words1.forEach(function(element1, index)

    {

     

      DS_1.setFilter("Words2", element1.internalKey);

      var arr_words2=DS_1.getMembers("Words2", 30);

      arr_words2.forEach(function(element, index)

         {

            LISTBOX_1.addItem( element1.text+element.text);

           });


    });


    Below output now in ListBox is:

    Product 1

    Product 2

    Word1Word2

    Word3Word4

    But My Expected Output in ListBox is:

    Product 1

      Word1Word2

    Product 2

      Word3Word4

    Tried achieving above output to write an On Apply script in Product Dimension Filter with same formatted output like above, but iam missing something here..

    Thanks,

    - Dinya.

    Add comment
    10|10000 characters needed characters exceeded

    • Hello Dinya,

      you already have the nested loops.

      so why don't you try in your code to first of all fill the array - one after the next - and then read values from the array - for example the first value in each array and put the output into a text field ?

      You asking people to provide you with final code here but it seems - at least to me - you not trying to troubleshoot the code yourself.

      you have 4 list of members, so why don't you create the first array, fill the array, read the first value and put the put into a text field.

      You do that for 4 separate arrays and first of all make sure that 4 separate arrays work and you see the right output.

      then you worry about the combination of text fields.

      regards

      Ingo Hilgefort