Tell me more ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I have researched this pretty thoroughly and everyone says that the code I have below should load SP.js, but I cannot get it to load.

Debugging I get:

NewForm.aspx, line 1667 character 5
SCRIPT5009: 'PeoplePicker' is undefined 

and do not see SP.JS under view sources.

<SharePoint:ScriptLink Name="SP.js" runat="server" OnDemand="true" 
    Localizable="false" /> 
<script type="text/javascript">

ExecuteOrDelayUntilScriptLoaded(SetWebUserData(), "SP.js");

function SetWebUserData() {
    var pplPicker = new PeoplePicker();
    // Set the parent tag id of the people the picker.
    pplPicker.SetParentTagId('Main_x0020_Contact');
    pplPicker.SetLoggedInUser();
    };
</script>

Any assistance greatly appreciated.

share|improve this question
SP.js is loading fine. The error is stating that you haven't defined the class PeoplePicker. If you have, then there's an error with that class or the script in which it is defined is not loading properly. – Elliot Bonneville May 9 at 14:04
I have defined PeoplePicker in the SP.js file and even when I delete all the code and just make PeoplePicker an alert function, I get no alert. I do not beleive that sp.js is loading fine. – user2366475 May 9 at 14:19
If I include PeoplePicker in the source code I still get an error – user2366475 May 9 at 14:26
on this line:this.context = new SP.ClientContext.get_current();SCRIPT5007: Unable to get property 'get_current' of undefined or null reference – user2366475 May 9 at 14:26

2 Answers

You are using ExecuteOrDelayUntilScriptLoaded wrong. You should only pass the function name, it should look like this:

ExecuteOrDelayUntilScriptLoaded(SetWebUserData, "sp.js");

Without the ()

share|improve this answer

I was able to resolve the issue and have people picker populated with the current user by using code found here: http://vbcity.com/blogs/skullcrusher/archive/2008/11/04/set-sharepoint-peoplepicker-field-mark-2.aspx

This code does not require SP.js

I was never able to get sp.js to load properly, but this solution fixes my problem.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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