I am using

 var schema = {};
    schema['PrincipalAccountType'] = 'SecGroup';
    schema['SearchPrincipalSource'] = 15;
    schema['ResolvePrincipalSource'] = 15;
    schema['AllowMultipleValues'] = true;
    schema['MaximumEntitySuggestions'] = 50;
    schema['Width'] = '370px';
    this.SPClientPeoplePicker_InitStandaloneControlWrapper(peoplePickerElementId, null, schema);

to allow groups only in a people picker in SharePoint forms, however when I load the edit or display forms, the selected picker values are being lost.

Any idea why this is happening please?

Instead of null, in the EditForm.aspx and displayForm.aspx I need to pass the selected users . Something like this:

var users = new Array(1);
var defaultUser = new Object();
defaultUser.AutoFillDisplayText = user.get_title();
defaultUser.AutoFillKey = user.get_loginName();
defaultUser.Description = user.get_email();
defaultUser.DisplayText = user.get_title();
defaultUser.EntityType = "User";
defaultUser.IsResolved = true;
defaultUser.Key = user.get_loginName();
defaultUser.Resolved = true;
users[0] = defaultUser;
SPClientPeoplePicker_InitStandaloneControlWrapper('peoplePickerDiv', users, schema);

but instead of "users" what should I put to display selected users ?

  • try to use solution below. Use your code but add get value before init action and set value after init. May be it will help you. – user80188 Dec 7 '18 at 17:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.