I am trying to set the value of a multi lookup field. I am rendering my field using CSR and using registerGetValueCallback
to get the value of my lookup field. But the value of my field does not update. I get no errors, neither in the UI nor the ULS log.
Here's what I have tried:
Register Callback:
if (modeNewEdit) {
let valueCallback = $.proxy(
() => {
return ChildContracts.arrayToFieldValue(this.childContracts);
}, this);
formCtx.registerGetValueCallback(formCtx.fieldName, valueCallback);
}
arrayToFieldValue (Version 1):
public static arrayToFieldValue(contracts: IChildContract[]) {
let value: string = "";
if (contracts.length > 0) {
contracts.forEach((c) => {
value = value + c.id.toString() + ";#" + c.title + ";#";
});
value = value.slice(0, value.length - 2);
}
return value;
}
arrayToFieldValue (Version 2):
public static arrayToFieldValue(contracts: IChildContract[]) {
let value = [];
if (contracts.length > 0) {
contracts.forEach((c) => {
let val = new SP.FieldLookupValue();
val.set_lookupId(c.id);
value.push(val);
});
}
return value;
}
I think the problem lies with the fact that my list item has a title field, but that field contains no value. The title value is set later in an ItemAdded ER. So I have tried Version 2 where I can only specify lookup id, but the result is the same. My multi lookup column isn't populated with any value and I get no error whatsoever. So can anybody shed some light on this?