I am trying to use the client-side People Picker and I can't get it to initialize the people picker due to SPClientTemplates not being defined. I am following MS documentation line by line but cannot figure out why it isn't defined.

Script Prereqs

<script type="text/javascript" src="https://sitecol.com/_layouts/15/clientforms.js">  </script>
<script type="text/javascript" src="https://sitecol.com/_layouts/15/clientpeoplepicker.js"></script>
 <script type="text/javascript" src="https://sitecoll.com/_layouts/15/autofill.js"></script>


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);

   /* I have also tried using ExecuteOrDelayUntilScriptLoaded to see if it is a timing 
      issue and that doesn't seem to be the case.

             this.SPClientPeoplePicker_InitStandaloneControlWrapper(peoplePickerElementId, null, schema);
       }, 'clientpeoplepicker.js');
 catch (err) {
    console.log('initializePeoplePicker: ' + err.toLocaleString());

Any help is much appreciated. Thanks.

  • @hu da the location is the same as clientforms.js "_layouts/15/clienttemplates.js" – Josh Henderson Jun 29 '17 at 12:39

Found the issue. I was not including a the clienttemplates.js... Eventhough it was appearing in Chrome resources.

<script type="text/javascript" src="js/clienttemplates.js"></script>

Location of clienttemplates.js:

--I'm sure this version is subject to change, but should be able to find new
--path in Chrome from an oob page.
  • 1
    ExceptionLimeCat clienttemplates.js is a js library if it where is the link to download Thanks – Hu Da Jun 16 '16 at 13:34
  • I'd also like to know where to find clienttemplates.js file – michalh Jul 21 '17 at 21:12
  • @MichalHainc js file location added. – ExceptionLimeCat Jul 24 '17 at 18:33
  • @ExceptionLimeCat yes found, but thanks anyway – michalh Jul 24 '17 at 19:31

Make sure that you have included all these files

<script src="/_layouts/15/sp.runtime.js"></script>  
<script src="/_layouts/15/sp.js"></script>  
<script src="/_layouts/15/1033/strings.js"></script>  
<script src="/_layouts/15/clienttemplates.js"></script>  
<script src="/_layouts/15/clientforms.js"></script>  
<script src="/_layouts/15/clientpeoplepicker.js"></script>  
<script src="/_layouts/15/autofill.js"></script>  
<script src="_layouts/15/sp.core.js"></script> 

I had the same issue and once I added all these file, it worked fine

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.