3

I have create a SharePoint 2013 peoplepicker field in an application page and want to show the SharePoint group only..

code: C#

    using (SPSite site = new SPSite("http://site/subsite"))
    { 
        SPUser user = null;
        ArrayList resolvedEntities = peoplePicker.ResolvedEntities;
        foreach (PickerEntity entity in resolvedEntities)
        {
            string loginName = entity.Key;
            user = site.RootWeb.EnsureUser(loginName);
            break;
        }
    }

ASPX:

      <SharePoint:ClientPeoplePicker
                Required="true"
                ValidationEnabled="true"
                ID="peoplePicker"
                runat="server"
                InitialHelpText="<%$Resources:wss,aclinv_PickerIntialHelperText%>"
                VisibleSuggestions="3"
                Rows="1"
                AllowMultipleEntities="false"
                CssClass="ms-long ms-spellcheck-true" />

Also, how to modify it to enable multi-selection?

1 Answer 1

4

For multiple selection Set AllowMultipleEntities="true" and for group set PrincipalAccountType = "SPGroup".

<SharePoint:ClientPeoplePicker
            Required="true"
            ValidationEnabled="true"
            ID="peoplePicker"
            runat="server"
            InitialHelpText="<%$Resources:wss,aclinv_PickerIntialHelperText%>"
            VisibleSuggestions="3"
            Rows="1"
            AllowMultipleEntities="true"
            PrincipalAccountType = "SPGroup"
            CssClass="ms-long ms-spellcheck-true" />

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.