4

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>

Code

function initializePeoplePicker(peoplePickerElementId) {
 try{
    // 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.

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

Any help is much appreciated. Thanks.

1
  • @hu da the location is the same as clientforms.js "_layouts/15/clienttemplates.js" Jun 29, 2017 at 12:39

2 Answers 2

2

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.
  https://mydomain.sharepoint.com/_layouts/15/16.0.6712.1210/clienttemplates.js
4
  • 1
    ExceptionLimeCat clienttemplates.js is a js library if it where is the link to download Thanks
    – Hu Da
    Jun 16, 2016 at 13:34
  • I'd also like to know where to find clienttemplates.js file
    – michalh
    Jul 21, 2017 at 21:12
  • @MichalHainc js file location added. Jul 24, 2017 at 18:33
  • @ExceptionLimeCat yes found, but thanks anyway
    – michalh
    Jul 24, 2017 at 19:31
0

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

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