I am trying to update a UserMulti field using CSR. However, no matter what value I send to SharePoint, the field remains empty.
This is my field definition:
<Field ID="{5EE8AF75-009D-4FBB-8AC9-D8D243170134}" Name="OnboardingStepResponsibleGroups" DisplayName="$Resources:Column_OnboardingSteps_OnboardingStepResponsibleGroups;" Type="UserMulti" UserSelectionMode="1" UserSelectionScope="0" Mult="TRUE" Group="Boardings Fields" />
I then register the field in my CSR file like so:
protected getTemplates(): SPClientTemplates.TemplateOverrides {
var templates: SPClientTemplates.TemplateOverrides = {};
templates.Fields = {
"OnboardingStepResponsibleGroups": {
NewForm: $.proxy(this.onboardingStepResponsibleGroupsNew, this)
}
};
return templates;
}
private onboardingStepResponsibleGroupsNew(ctx: SPClientTemplates.RenderContext_FieldInForm): string
{
var formCtx = SPClientTemplates.Utility.GetFormContextForCurrentField(ctx);
var field = new BoardingStepResponsibleGroupsNew("boardingreposiblegroup_new");
formCtx.registerInitCallback(formCtx.fieldName, $.proxy(field.initCallback, field));
formCtx.registerGetValueCallback(formCtx.fieldName, $.proxy(field.getValueCallback, field));
return field.render();
}
This is my callback function:
public getValueCallback(): any {
var values: SP.FieldUserValue[] = [];
this.groups.forEach((group) => {
if (group.Selected) {
var value: SP.FieldUserValue = new SP.FieldUserValue();
value.set_lookupId(group.ID);
values.push(value);
}
});
return values;
}
I have tried returning everything from an array of anonymous objects to an array of SP.FieldUserValue. However, no matter what I do, the field is always empty. Also, when I use
var spReponsibleGroups: string = ctx.CurrentItem["SomeMultiUserField"];
I get different values for display and edit forms. When inside display forms, the value is a string and looks like 1;#blah blah;#2;#ble ble
but inside the edit form, the value looks like this:
[{
Description: "Boarding Administratoren",
DisplayText: "Boarding Administratoren",
EntityGroupName: "",
EntityType: "",
HierarchyIdentifier: null,
IsResolved: true,
Key: "Boarding Administratoren",
MultipleMatches: [],
ProviderDisplayName: "",
ProviderName: ""
},
{
Description: "Boarding HR-PUL-Technik",
DisplayText: "Boarding HR-PUL-Technik",
EntityGroupName: "",
EntityType: "",
HierarchyIdentifier: null,
IsResolved: true,
Key: "Boarding HR-PUL-Technik",
MultipleMatches: [],
ProviderDisplayName: "",
ProviderName: ""
}]
Official SharePoint documentation is lacking, as usual and I haven't had luck finding anything that's specifically about UserMulti fields targeting groups. Can anybody please help me out as I am all out of ideas?
SPClientPeoplePicker
available in the global namespace? Can you tell if theclientpeoplepicker.js
script was loaded by SharePoint?clientpeoplepicker.js
, I was mentioning that because the way you worded your question, I was under the impression you were having issues with the control on the client side. I'm not sure I'm clear on what exactly you are having a problem with, then. How are you trying to set the field value? A REST call?