Hi!
I am working on a panel where I am storing a Value as a Key Value Constraint in a param, so a dropdown widget can show a name, and a corresponding value (long string ID) can be passed into a script.
I would like to have two text entry boxes and a button with a task to add the value of those text boxes as a key/value constraint.
I have tried to adapt the replacing/get constraints sample .grid file to get this to work, I feel like I am close, but I cannot figure out why when it adds the new constraint, it is not reading the existing key values for the constraints with .getValue().
Any input would be greatly appreciated
<abs contexttype="opengear" gridsize="20" id="_top">
<meta>
<params>
<param access="1" constraintstrict="false" constrainttype="STRING_STRING_CHOICE" maxlength="0" name="Sheet_ID" oid="Sheet_ID" type="STRING" value="0" widget="default">
<constraint key="1JeBg61Gep2n2OQh7aUiNV_R9Bb8">DEFAULT</constraint>
<constraint key="15v8TMXWxkY">SHOW A</constraint>
<constraint key="1Kg_jNIhsHh-hoUA-hXm7MEWyofXcU">SHOW B</constraint>
</param>
<param access="1" maxlength="0" name="new_ID" oid="new_ID" type="STRING" value="123456789" widget="text"/>
<param access="1" maxlength="0" name="new_Name" oid="new_Name" type="STRING" value="testing" widget="text"/>
</params>
</meta>
<param expand="true" height="120" left="180" oid="Sheet_ID" showlabel="false" top="60" widget="combo" width="400"/>
<button buttontype="push" height="60" left="940" name="ADD SHOW" top="260" width="160">
<task tasktype="ogscript">var existValues = params.getConstraint('Sheet_ID').getChoices();
var newName = params.getValue('new_Name', 0);
var newID = params.getValue('new_ID',0);
var newValues = []
var numList = params.getConstraint("Sheet_ID");
var choices = numList.getChoices();
for (var i = 0; i < choices.length; i++) {
newValues.push({"key": choices[i].getValue(), "value": choices[i].getName()});
}
newValues.push({"key": newID, "value": newName});
var newCon = params.createStringStringChoiceConstraint(newValues);
params.replaceConstraint('Sheet_ID', newCon);</task>
</button>
<param expand="true" height="40" left="200" oid="new_ID" showlabel="false" top="280" widget="combo" width="360"/>
<param expand="true" height="40" left="760" oid="new_Name" showlabel="false" top="280" width="120"/>
<label height="20" left="60" name="New Google Sheet ID" style="txt-align:west" top="280" width="140"/>
<label height="20" left="620" name="Show Name" style="txt-align:west;" top="280" width="160"/>
</abs>
------------------------------
Evan Aaron
Engineer
Game Creek Video
------------------------------