This project has moved and is read-only. For the latest updates, please go here.

PeoplePicker Sharepoint 2013

Aug 13, 2013 at 10:23 AM
Edited Aug 13, 2013 at 10:24 AM
Hello Kit,

My Problem:
I can't fill a PeoplePickerField automatically in SharePoint 2013.

Maybe a solution:
I found in your "SPUtility.js" the following:

on Line 790
var controls ='');
        if (null !== controls && 1 === controls.length) {
            this.spanUserField = controls[0];
            this.upLevelDiv = $( + '_upLevelDiv');
The first argument doesn't work correctly because "controls[0]" is "null".
And so the "this.upLevelDiv" is also "null". (but we need this to write the value in the PeoplePickerField "this.upLevelDiv.innerHTML = value" on Line 811)

I hope you have a solution for me.

Best Regards,

->MY Code:
<script src="/Style%20Library/prototype.js" type="text/javascript"></script>
<script src="/Style%20Library/SPUtility.js" type="text/javascript"></script>
<script type="text/javascript">

    SPUtility.GetSPField('MyField').SetValue('Lastname Firstname').MakeReadOnly();
  catch (ex) {} 

Aug 14, 2013 at 7:31 AM

with SPUtility.Debug(true); I get the error Message:
GetSPField: Unable to find a SPField named Title
I get this error on every field. Is this a Problem with SharePoint 2013 ?
Aug 14, 2013 at 3:40 PM
Thanks for reporting this. I recently got access to a 2013 environment and was able to reproduce this error there.

I'm going to see if I can implement a fix.
Aug 16, 2013 at 10:34 PM
I wanted to give you a quick update on what I've found out so far.

First, I am sorry to report that SPUtility, as it is now, will NOT work with SharePoint 2013. Prototype.js breaks out of the box SP2013 functionality (unrelated to people fields or really even SPUtility.js).

Second, I have been working (slowly) on a jQuery version of SPUtility.js in an effort to get rid of prototype.js. jQuery works fine in SharePoint 2013. It is my plan to discontinue this version once I have the jQuery version working.

Third, people fields in SharePoint 2013 are much, much different than they were in 2007 and 2010. It should be possible to manipulate these fields but I have a lot of Microsoft's code to read. :)
Aug 26, 2013 at 12:48 PM

I've found a Little Workaround. I hope i won't need it any longer... ;)

1) Set a SP-Textfield with current user
<script language="javascript" src="/Style%20Library/kcs/js/jquery-1.10.2.min.js" type="text/javascript"></script>
<script language="javascript" type="text/javascript">

//Load Document - wait
SP.SOD.executeFunc('sp.js', 'SP.ClientContext', setPicker);

function setPicker() 
  //Read current user
  var ctx = SP.ClientContext.get_current(),
      web = ctx.get_web(),
      currentUser = web.get_currentUser();

  ctx.executeQueryAsync(function () 
        $("").each(function () 
          //Insert Current user into field "SPFIELD"
      }, function (sender, args) 
        alert("ERROR: " + args.get_message());
2) Use a SharePoint - Standard Workflow to set the People-Picker Field with the Content from the textfield.

There's just one Problem:
  • if the user edits the textfield - maybe PeoplePicker can't load the right Person.
Thank you, and have a succesful day/week!