Uncaught ReferenceError: EnsureScript is not defined for PeoplePicker in SharePoint Custom Form

Michael Williams 21 Reputation points
2021-10-29T15:45:30.603+00:00

When I implement the People Picker control on a custom page, I get the "Uncaught ReferenceError: EnsureScript is not defined" Can someone help?

// Render and initialize the client-side People Picker.
function initializePeoplePicker(peoplePickerElementId) {

// 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'] = true;
schema['MaximumEntitySuggestions'] = 50;
schema['Width'] = '280px';

// Render and initialize the picker. 
// Pass the ID of the DOM element that contains the picker, an array of initial
// PickerEntity objects to set the picker value, and a schema that defines
// picker properties.
this.SPClientPeoplePicker_InitStandaloneControlWrapper(peoplePickerElementId, null, schema);

}

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.
2,668 questions
{count} votes

1 answer

Sort by: Most helpful
  1. RaytheonXie_MSFT 31,071 Reputation points Microsoft Vendor
    2021-11-02T05:37:34.407+00:00

    Hi @Michael Williams ,
    Here is the code snippet about adding Client People Picker in SharePoint Hosted app for your reference, I would suggest you to check:

    In Default.aspx, Reference file under PlaceHolderMain:
    145654-default.txt

    In App.js, write Script below, not use this, it might cause xxx object is not defined:
    145678-app.txt

    Here is the document for reference
    https://learn.microsoft.com/en-us/sharepoint/dev/sp-add-ins/use-the-client-side-people-picker-control-in-sharepoint-hosted-sharepoint-add-in


    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