Is it possible to prevent a user from inputting multiple values (users/groups) in the people picker (SharePoint:PeopleEditor)?
Thanks
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It only takes a minute to sign up.
Sign up to join this communityDavid,
I guess there is a MultiSelect property which you can set to false to allow only a single entry of User/Group
For example:
PeopleEditor Control - The article is for SP 2007 but I hope its the same in 2013
That depends where you are using it.
If you are just using it via a list field, then set the properties for that field.
If you are using it as a server side control in your code then refer to MSDN for all the properties. The specific property you want to set is:
peopleEditor.MultiSelect = false;
Karine Bosch also has a really good article on how to use the people picker in server side code
If you are using it as a client side control refer this MSDN article . When your initializing the control set the schema appropriately. Eg:
// Create a schema to store picker properties, and set the properties.
var schema = {};
schema['PrincipalAccountType'] = 'User,DL,SecGroup,SPGroup';
schema['SearchPrincipalSource'] = 15;
schema['ResolvePrincipalSource'] = 15;
schema['AllowMultipleValues'] = false;
schema['MaximumEntitySuggestions'] = 50;
schema['Width'] = '280px';
Yes, it is possible.
In SP List, while creating a People picker, there is an option 'Allow Multiple Values' which is by default set to 'No'. After creating the field, if we try to enter multiple values, it will give us a warning and won't allow us to save the item untill we correct it.
In Infopath form, we can do the same thing by applying rules on the field. Define a rule which checks everytime the number of items in the control (People will be stored as Repeating field only) and alert accordingly.
Hope this helps.