0

I have some people picker fields in a new custom form. The original form has the type ahead feature - searching the specific SharePoint groups.

I am able to change the fields in SP Designer from SharePoint:FormField to SharePoint:ClientPeoplePicker. Once I choose the SharePoint:ClientPeoplePicker I also loose the SharePoint group I am wanting to search - instead I get a full AD list which is not going to work due to permissions set within the form - not to mention the confusion for the end user.

I really need the solution to search the persons inside the specified SPGroup.

Is there a way to do this in SP designer or with some script?

2
  • you mean you want to make person search in specific SP group? can you add you people picker code ? May 29 '17 at 4:19
  • Yes - specific SP groups. I don't have people picker code
    – garvon-77
    May 29 '17 at 4:22
2

Default behaviour limits the ClientPeoplePicker to return only users from SharePoint, the ClientPeoplePicker does not return SPGroups or Active Directory Groups or Security Groups nor Distribution Groups.You can configure client side people picker to get groups as below.

Follow below steps

1.Add references

<SharePoint:ScriptLink name="clientforms.js" runat="server" LoadAfterUI="true" Localizable="false"/>
<SharePoint:ScriptLink name="clientpeoplepicker.js" runat="server" LoadAfterUI="true" Localizable="false"/>
<SharePoint:ScriptLink name="autofill.js" runat="server" LoadAfterUI="true" Localizable="false"/>

<script type="text/javascript" src="../SiteAssets/jquery-1.11.1.js"></script>
<script type="text/javascript" src="../SiteAssets/SPReferences/MicrosoftAjax.js"></script>
<script type="text/javascript" src="../SiteAssets/SPReferences/sp.runtime.js"></script>
<script type="text/javascript" src="../SiteAssets/SPReferences/sp.js"></script>

2.Initialize peoplepicker

$(document).ready(function(){
         SetPeoplePicker_Multiselect("peoplePickerspanId",true);  
    });
    function SetPeoplePicker_Multiselect(peoplePickerElementId, allowMultiple){
        if (allowMultiple == null) {
            allowMultiple = true;
        }
        var schema = {};
        schema['PrincipalAccountType'] = 'User,DL,SecGroup,SPGroup';
        schema['SearchPrincipalSource'] = 15;
        schema['ResolvePrincipalSource'] = 15;
        schema['AllowMultipleValues'] = allowMultiple;
        schema['MaximumEntitySuggestions'] = 50;
        schema['Width'] = '';
        SPClientPeoplePicker_InitStandaloneControlWrapper(peoplePickerElementId, null, schema);
    }

3.Add Markup to page

<span id="peoplePickerspanId"> </span>

you can tweak it more as per your requirements.

9
  • Where do I find the references? I am not able to see these under site assets...
    – garvon-77
    May 30 '17 at 23:35
  • How do I use this code - do I link it to the web part?
    – garvon-77
    May 31 '17 at 1:16
  • 1
    The references except jQuery you will find js at "_layouts/15/" ( <script type="text/javascript" src="_layouts/15/sp.runtime.js"></script>) For some reason i had copied it to my site assets. You will have to create a custom page and add this entire code to. May 31 '17 at 1:23
  • How will my custom form read this custom page?
    – garvon-77
    May 31 '17 at 2:20
  • If you have created custom form, then you can edit in designer and setup the above code. You can edit html in your form to get this done. Refer this for more social.technet.microsoft.com/wiki/contents/articles/… May 31 '17 at 2:31

Your Answer

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

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