سؤال

I would like to create a people-picker user field where more than one user can be chosen.

Currently, this is what I'm doing:

SPField field = new SPField(contentType.Fields, "User", "Users");
SPFieldLink fieldLink = new SPFieldLink(field);
contentType.FieldLinks.Add(fieldLink);
contentType.Update();

However, I imagine this only creates a field to select a single user.

هل كانت مفيدة؟

المحلول

Cast it to an SPFieldUser, or create an SPFieldUser in the first place, and set AllowMultipleValues to true.

نصائح أخرى

you can use only AddFieldAsXml because Multiselect User Field is marked as non-UserCreatable :)

list.fields.AddFieldAsXml(<Field Type="UserMulti" DisplayName="My_User_Field" Required="FALSE" UserSelectionMode="PeopleAndGroups" UserSelectionScope="0" Mult="TRUE" Sortable="FALSE" ID="{7293d78b-f9b3-4cce-b85f-ac499fc4fcf2}")
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى sharepoint.stackexchange
scroll top