PeoplePicker and JQuery

MLEONKC 1 Reputation point
2022-05-09T19:20:56.103+00:00

I have a custom page I am developing. I want to mimic the SharePoint peoplepicker on an HTML5/JQuery page. How would I go about that? Is there a way to export the site's users to XML and build the picker that way? Or is there a more straight-forward way?

SharePoint Development
SharePoint Development
SharePoint: A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.Development: The process of researching, productizing, and refining new or existing technologies.
3,198 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Tong Zhang_MSFT 9,236 Reputation points
    2022-05-10T06:58:05.57+00:00

    Hi @MLEONKC ,

    Based on my research and testing, you can follow the script below to build the People Picker:

    $(document).ready(function() {    
        initializePeoplePicker("_UserName");    
    });    
    function initializePeoplePicker(peoplePickerElementId) {    
        var schema = {};    
        schema['PrincipalAccountType'] = 'User,DL,SecGroup,SPGroup';    
        schema['SearchPrincipalSource'] = 15;    
        schema['ResolvePrincipalSource'] = 15;    
        schema['AllowMultipleValues'] = false;    
        schema['MaximumEntitySuggestions'] = 50;    
        schema['Width'] = '280px';    
        this.SPClientPeoplePicker_InitStandaloneControlWrapper(peoplePickerElementId, null, schema);    
    }    
    

    My test code and result:
    200561-image.png
    200496-image.png


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


    0 comments No comments

  2. MLEONKC 1 Reputation point
    2022-05-10T12:59:27.327+00:00

    Thanks - I get about 4 errors:

    • Strings is not defined in clienttemplates.js
    • ExecuteOrDelayUntilScriptLoaded is not defined in clientforms.jsp
    • jQuery.deferred exception: EnsureScript is not defined in jquery.min.js
    • Same error at the SPClientPeoplePicker line...

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.