1

I have a HTML Webpart with the following code (piece):

<script type="text/javascript" src="../../SiteAssets/jquery-1.12.0.min.js"></script>

<script type="text/javascript" src="../../SiteAssets/sputility.min.js"></script>

<div id="peoplePickerDiv"></div>
<div>
    <br/>
    <input type="button" value="Get User Info" onclick="getUserInfo()"></input>
    <br/>
    <h1>User info:</h1>
    <p id="resolvedUsers"></p>
    <h1>User keys:</h1>
    <p id="userKeys"></p> 
    <h1>User ID:</h1>
    <p id="userId"></p>
</div>

<script>
  // Run your custom code when the DOM is ready.
  $(document).ready(function () {

    // Specify the unique ID of the DOM element where the
    // picker will render.
    initializePeoplePicker('peoplePickerDiv');
  });

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

  function getUserInfo() {
    ...
  }
</script>

The code is from the example here: https://msdn.microsoft.com/de-de/library/office/jj713593.aspx

I want to use it in my Provider Hosted App, to set the "Assigned To" field of selected items to the person, that is selected here.

For me the strange thing is the following: In the EditView.aspx this code without any changes works well! But won't for AllItems.aspx.

My IE Console sais: Das Objekt unterstützt die Eigenschaft oder Methode "SPClientPeoplePicker_InitStandaloneControlWrapper" nicht (= The object doesn't support the property or method "SPClientPeoplePicker_InitStandaloneControlWrapper")

enter image description here

What am I doing wrong here? What is the this in this.SPClientPeoplePicker_InitStandaloneControlWrapper (is here somethoing wrong?). Thank you!

Here are two screenshots of EditForm (Webpart ok, red circle): enter image description here

and AllItems (Webpart doesn't contain the e-mail / user input field): enter image description here

  • A person/group field in an allitems view is going to be standard html markup, not the complex field type in an editform. The allitems view isn't going to be a settable field like the editform. – Eric Alexander Feb 19 '16 at 13:09
  • Ok, thank you! But the code piece above, where I call the SPClientPeoplePicker_InitStandaloneControlWrapper method should work, shouldn't it? My plan is to load the selected items by their IDs and then set the (complex) AssignedTo field later... – D. Müller Feb 19 '16 at 13:20
  • No, not likely, there is no people picker on the all items view – Eric Alexander Feb 19 '16 at 13:46
  • But as I understood the init method should generate such an input field. It is also displayed in the webpart's div and seems to be independent to the list below. – D. Müller Feb 19 '16 at 13:48
0

I found another question here: ReferenceError: SPClientTemplates is not defined

He was missing some Script references. This did also the job for me!

Here are the "added" references:

<script type="text/javascript" src="https://server.sharepoint.com/sites/site1/_layouts/15/clientpeoplepicker.js"></script>

<script type="text/javascript" src="https://server.sharepoint.com/sites/site1/_layouts/15/autofill.js"></script>

<script type="text/javascript" src="https://server.sharepoint.com/sites/site1/_layouts/15/clienttemplates.js"></script>

Don't know why I have to use them in AllItems.aspx, but don't have to in EditForm.aspx...

| improve this answer | |

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.