I am trying to inject data into the correct fields when making a component. So far I am able to inject data into Text fields, Number fields, Date fields, Multi-value fields. I use this function to do this.
Utilities.PushValuesToField = function PushValuesToField(fieldId, values) {
var p = this.properties;
var item = $display.getItem();
if (item) {
if (item.getItemType() == "tcm:16") {
var fieldBuilder = $display.getView().properties.controls.fieldBuilder;
if (fieldBuilder.getField(fieldId)) {
var field = fieldBuilder.getField(fieldId);
var countOfValues = values.length;
if (countOfValues > 0) {
field.setValues([values[0]]);
try{
for (var iValue = 1 ; iValue < countOfValues ; iValue++) {
var addedField = fieldBuilder.properties.input.insertField(field);
addedField.setValues([values[iValue]]);
field = addedField;
}
} catch (err) {
return 100;
}
}
}
}
}
};
Now I would like to be able to do the same but then for Embedded schemas. So making a function where I can give an id and a value and put that value in the correct field.