SPFindPeoplePicker stop updating values.

Mar 9, 2015 at 8:28 PM
For some reason my PeoplePicker stop updating the current user value.

I get the login user name and id, then try to use SPFindPeoplePicker but the Picker is empty.

<script type="text/javascript" src="../../Scripts/jquery-1.11.1.min.js"></script>
<script type="text/javascript" src="../../Scripts/jquery.SPServices-2014.01.min.js"></script>

<script type="text/javascript">
SP.SOD.executeOrDelayUntilScriptLoaded(initializeUser,"sp.js")

function initializeUser(){
var ctx=SP.ClientContext.get_current();
var web=ctx.get_web();
var list=web.get_lists().getByTitle("Weekly Status");

user=web.get_currentUser();

ctx.load(user);
ctx.executeQueryAsync(Function.createDelegate(this,userSuccess),Function.createDelegate(this,onFail))
}

function userSuccess(){
var columnName = 'Updated By';
var userName = user.get_title();
var loginName = user.get_loginName();

alert(loginName);

var pp = $().SPServices.SPFindPeoplePicker({
    peoplePickerDisplayName: "Updated By",
    valueToSet: userName,
    checkNames: true
}); 
}

function onFail(sender, args){alert(args.get_message())}
Coordinator
Mar 9, 2015 at 8:30 PM
Your call to SPFindPeoplePicker seems correct. I'd suggest debugging to make sure that you're actually getting a value for the userName variable.

M.
Mar 9, 2015 at 9:01 PM
Looks like if the Picker wasnt found.

I got the rigth values for userName but the value wasnt updated.

I dont know if this is right, but already test directly with an existing user without success.

var pp = $().SPServices.SPFindPeoplePicker({
peoplePickerDisplayName: "Updated By",
valueToSet: "John Doe",
checkNames: true
});
Coordinator
Mar 9, 2015 at 9:05 PM
Edited Mar 10, 2015 at 8:29 PM
What version of SharePoint are you running? did you apply any patches or anything just prior to this stopping working?

M.
Mar 9, 2015 at 9:19 PM
SP 2010.
Not Patching just add a new Field and Update the form.

But, I builded a new one and also the SPPicker wasnt populated.

function userSuccess(){
var columnName = 'Updated By';
var userName = user.get_title();
var loginName = user.get_loginName();

alert(loginName);

var pp = $().SPServices.SPFindPeoplePicker({
    peoplePickerDisplayName: "Updated By",
    valueToSet: loginName,
    checkNames: true
}); 

console.log(pp);
}

Object {row: m.fn.init[0], contents: m.fn.init[0], currentValue: "", checkNames: m.fn.init[0], dictionaryEntries: Array[0]}
Mar 10, 2015 at 3:31 PM
This is my html in Sharepoint Designer:

<tr>
<td width="190px" valign="top" class="ms-formlabel">
<H3 class="ms-standardheader">
       <nobr>Updated By</nobr>
</H3>
</td>
<td width="400px" valign="top" class="ms-formbody">
<SharePoint:FieldDescription runat="server" id="ff9description{$Pos}" FieldName="Updated_x0020_By" ControlMode="New"/>
    <span id="part2">
    <SharePoint:FormField runat="server" id="FormField1" ControlMode="New" FieldName="Updated_x0020_By" __designer:bind="{ddwrt:DataBind('i',concat('ff9',$Pos),'Value','ValueChanged','ID',ddwrt:EscapeDelims(string(@ID)),'@Updated_x0020_By')}" />
    </span>
</td>
</tr>

also tried the function you provided on your site:

$.fn.findPeoplePicker = function(options) { ...

looks like if at this point any row was founded:

var thisRow = $("nobr").filter( ...
Coordinator
Mar 10, 2015 at 8:31 PM
What I was looking for was the markup from the browser. What you show above will generate different markup for the browser.

That said, it looks like you've converted the form to XSLT. Depending on what changes you've made, that could be a part of the problem. The SPFindPeoplePicker function is going to look for the markup in the page that the default People Picker generates.

M.
Mar 10, 2015 at 8:41 PM
Thanks to the $.fn.findPeoplePicker function that you had provided, I found the error.

Was an "enter", that was added when the aspx page was edited on sharepoint desginer.

Thanks a lot Marc.
Coordinator
Mar 10, 2015 at 8:54 PM
Oh, great! Glad to hear you got it working again.

M.