# Array to Parameter

**URL:** <https://rossvideo.community/t/array-to-parameter/8242>\
**Category:** Automation & Control\
**Created:** [December 29, 2018, 12:26am UTC](https://rossvideo.community/t/array-to-parameter/8242 "2018-12-29T00:26:00Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ryanmccarthy\_2](https://rossvideo.community/letter_avatar_proxy/v4/letter/r/bbce88/32.png) [@ryanmccarthy\_2](https://rossvideo.community/u/ryanmccarthy_2)\
**Post date:** [December 29, 2018, 12:26am UTC](https://rossvideo.community/t/array-to-parameter/8242/1 "2018-12-29T00:26:00Z")

</div>

I’m having some trouble pushing an array to a string array parameter.

Here is a quick example of what I’m trying to do.

Upon executing the code, nothing gets written to the parameter and no errors pop up in the debug console.

What am I missing here?

 0 var testArr = ["Apples", "Oranges", "Bananas"]; var cArray = []; var x = testArr.length; for (var i = 0; i \< x; i++) { cArray.push({"key":i,"value":testArr[i]}); } var choiceConstraint = params.createIntChoiceConstraint(cArray); params.replaceConstraint("List", choiceConstraint);

---

<div class="post-metadata">

**Author:** ![aleksanderstalsberg](https://rossvideo.community/letter_avatar_proxy/v4/letter/a/cab0a1/32.png) [@aleksanderstalsberg](https://rossvideo.community/u/aleksanderstalsberg)\
**Post date:** [January 2, 2019, 6:24pm UTC](https://rossvideo.community/t/array-to-parameter/8242/2 "2019-01-02T18:24:00Z")

</div>

Well there’s two things to this one…

1: You are trying to push a value pair with an integer identifier into a string array that only contains one set of data.  
So if you want to use a “String Array” you dont need the key/value pair, but just an array of string values.  
You must also use the “params.createStringChoiceConstraint” instead.

The below example will change the values of the dropdown to your "apples, oranges, bananas.

 String 1 String 1 String 2 String 3 var testArr = ["Apples", "Oranges", "Bananas"]; 

var choiceConstraint = params.createStringChoiceConstraint(testArr);  
params.replaceConstraint(“List”, choiceConstraint);  
  
  
It does not update the allready selected dropdown value, but if you click the button, then the dropdown, you’ll see the new options.

2: If you want to identify each entry by a number (int) instead, you have to change your parameter into an “Int Array” with “choice constraint”.  
As you might notice, now you have a value on each entry pluss the string value.  
Set it to dropdown default or change the widget once placed.

Then the below code would work (wich is more similar to yours):

 String 1 String 2 String 3 var testArr = ["Apples", "Oranges", "Bananas"]; var cArray = []; var x = testArr.length; for (var i = 0; i \< x; i++) { cArray.push({"key":i,"value":testArr[i]}); } var choiceConstraint = params.createIntChoiceConstraint(cArray); params.replaceConstraint("List", choiceConstraint); Note: This one will actually change the selected value in the dropdown before opening it again.

[#DashBoard](https://livinglive.community/search?s=tags%3A%22DashBoard%22&executesearch=true)
