Following this very nice page, I am trying to insert multiple component links in one go through JavaScript:
var fieldsBuilder = $display.getView().properties.controls.fieldBuilder;
// The Field Type = Tridion.FieldBuilder.FieldTypeHandlers.ComponentLinkField
var currentField = fieldsBuilder.getField(currentFieldName);
// Get the multivalued data
var selectList = document.getElementById("selectedList");
var selectListOptions = selectList.getElementsByTagName("option");
var newValues = new Array();
for (var i=0;i<selectListOptions.length;i++){
newValues.push(selectListOptions[i].value);
}
currentField.setValues(currentField.getValues().concat(newValues));
For this field type I get a "This field allows a single value only." error, which makes a lot of sense, because the setValues function for this field type gives this:
function (b){
var a=this,c=false;
if(b&&a.properties.input)if(b.length>1)
$assert.raiseError("This field allows a single value only.");
else if(b.length==1){
// ETC
.. while I am trying to insert an array of tcm IDs.
I probably have to do this in a totally different way, but can't really find any. Can anyone here help me out?