When I talked about how to update fields in SharePoint, I was talking about the easy stuff: input fields and stuff. Now, I wanted to update / set a SharePoint people field on my form.
I did some googling and found a solution by Marc D. Anderson (in my opinion he is THE authority on sharepoint jQuery 😉 ) but I couldn’t get that to work here.
I also found a really easy solution by Dave Cavins who uses the class to define the people picker. Only bad thing with this solution is that it updates all people pickers:
Combined with SPServices it gives the following result to automatically fill in the current user:
<script type="text/javascript"> $(document).ready(function() { $('div.ms-inputuserfield').text($().SPServices.SPGetCurrentUser({fieldName: "Title",debug: false})); }); </script>
In the mean time, a far better solution has arisen (like the comment from Marc says) that allows you to address a specific SharePoint people field with the help of the almighty SPServices:
</pre> $().SPFindPeoplePicker({ peoplePickerDisplayName: "", valueToSet: "", checkNames: true });
This code allows you to set a SharePoint people field by pointing to its name, add the value you want it to be and if you want it “checked”.
Check out my recent post called Working with SharePoint People Pickers with jQuery: A New Function Called findPeoplePickerabout a new function I’m working on. It gives you a lot more control with People Pickers. I’ve updated it to parse out the email, account, and name as well, but I haven’t posted that yet.
M.
Wow, thanks Marc !!
I already checked out the solution this week and I will use that in future projects!!
Wow, Thanks.
Just spend 2 hours getting it to work. You just made me do it in 15 seconds!
Nice solution
Hello,
I want People Picker Control in SharePoint 2010.I tried above solution, can you please tell me what jquery reference we have to refer, in my case user is not resolving