Skip to Content

Using dynamic array to set checkbox selected values

I've run into a issue with Design Studio 1.6 where I'm trying to set the selected value of a checkbox group. I've got a script function where I get the members of a filtered datasource and i'm trying to use them to set my checkbox selected value method.

Example is. I get members from my filtered list that contains A,B,C. The checkbox group I've created has A,B,C,D,E,F.

I'm using CheckboxGroup.setSelectedValue() method to set the selected values. When manually setting the array of ckbxgrp.setSelectedValue(["A","B","C"]) it will set the proper values selected. Issue is when I try to pass that same array string that is created dynamically using a foreach loop it doesn't like the values pass and doesn't set any of the values selected.

Add comment
10|10000 characters needed characters exceeded

  • Hi Vi,

    Can you share the script code you are applying to dynamically create the array string?

    Regards,

    Mustafa.

  • Here's my code below. Simple foreach loop that builds my list.

    beginQuote = '["';
    items.forEach(function(element, index) {	
    	if(index >= 1){
    		if(index == 1){
    			itemList = beginQuote + element.externalNoncompoundedKey;
    		}
    		else{
    			itemList = itemList + '","' + element.externalNoncompoundedKey;	
    		}		
    
    		if(index == items.length-1){
    			itemList = itemList + '"]';
    		}
    	}
    });
    
    CHKBOXGRP.setSelectedValues(itemList);
    

    If I manually create the array it works fine. Example CHKBOXGRP.setSelectedValues(["test1","test2"]); Also the external and internal values are the same.

  • Follow
  • Get RSS Feed

1 Answer

  • Jul 26, 2018 at 12:45 PM

    Looks like I found the solution from this question. How simple it was but I would have never thought to do it like what was described.

    https://archive.sap.com/discussions/thread/3745474

    Add comment
    10|10000 characters needed characters exceeded