Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8756497
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T14:05:42+00:00 2026-06-13T14:05:42+00:00

I’m using sharepoint services 3.0 and I’ve created a custom list form. I have

  • 0

I’m using sharepoint services 3.0 and I’ve created a custom list form. I have in this form a peoplepicker field and need it to be set by default to the current user.

This is what I’ve got so far:

  • First my peoplepicker fonction:

    function PeoplePicker(){

    this.context = null;
    this.web = null;
    this.currentUser = null;
    this.parentTagId = null
    
    this.SetParentTagId = function(id){
        this.parentTagId = id;
    }
    
    this.SetLoggedInUser = function(){
        if(this.parentTagId != null){
            this.getWebUserData();
        }
    }
    
    this.getWebUserData = function(){
        this.context = new SP.ClientContext.get_current();
        this.web = this.context.get_web();
        this.currentUser = this.web.get_currentUser();
        this.currentUser.retrieve();
        this.context.load(this.web);
        this.context.executeQueryAsync(Function.createDelegate(this, this.onSuccessMethod),
                                       Function.createDelegate(this, this.onFailureMethod));
    }
    
    this.onSuccessMethod = function(){
        this.setDefaultValue(this.currentUser.get_title());
    }
    
    this.onFailureMethod = function(){
        alert('request failed ' + args.get_message() + '\n' + args.get_stackTrace());
    }
    
    this.setDefaultValue = function(value){
        var parentTag = document.getElementById(this.parentTagId);
        if (parentTag != null) {
            var peoplePickerTag = this.getTagFromIdentifierAndTitle(parentTag, 'div',
                                                    'UserField_upLevelDiv', 'People Picker');
            if (peoplePickerTag) {
                peoplePickerTag.innerHTML = value;
            }
        }
    }
    
    this.getTagFromIdentifierAndTitle = function(parentElement, tagName, identifier, title){
        var len = identifier.length;
        var tags = parentElement.getElementsByTagName(tagName);
        for (var i = 0; i < tags.length; i++) {
            var tempString = tags[i].id;
            if (tags[i].title == title && (identifier == "" ||
                                tempString.indexOf(identifier) == tempString.length - len)) {
                return tags[i];
            }
        }
        return null;
    }
    

    }

  • secondly the way I use it in my asp content :

ExecuteOrDelayUntilScriptLoaded(SetWebUserData, “PeoplePicker.js”);

function SetWebUserData() {
var pplPicker = new PeoplePicker();
// Set the parent tag id of the people the picker.
pplPicker.SetParentTagId(‘ctl00_PlaceHolderMain_g_ec44fef5_c1a6_4ade_b7e4_2b80803724a1_ff6_1_ctl00_ctl00_UserField’);
pplPicker.SetLoggedInUser(); }

But nothing happens when I load the form…Am I using the wrong parent tag ID? I took it from the source code of the page…

Any help would be great !

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T14:05:44+00:00Added an answer on June 13, 2026 at 2:05 pm

    Here is how I do it.

    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
    <script type="text/javascript"> 
    $(window).load(function(){
    var columnName = 'Manager Name';   
    var searchText = RegExp("FieldName=\"" + columnName + "\"", "gi");
    $("td.ms-formbody").each(function() {  
    if(searchText.test($(this).html())) {  
    $(this).find("div[Title='People Picker']").html(getUserName());  
    return false;  
    }  
    });
    function getUserName() { 
    var wshell=new ActiveXObject("wscript.shell"); 
    var userName=wshell.ExpandEnvironmentStrings("%username%");  
    return userName;}   
    });
    </script>
    

    My people picker field is named ‘Manager Name’ but it is a variable so you can change it. I use the function getUserName() to set the value of the people picker. getUserName uses the Environment String username. Some people will tell you that is not the best thing to use because it can be ‘faked’. I am in a corporate environment where this is tightly controlled. Personally I don’t think most user will even know how to do that.

    I think the issue you are having is the value a people picker field needs is not just a string. I believe it is looking for a key value pair which would mean you need the user name and ID number assigned in the SharePoint site. To get around this the code I use just puts the username sting in the html form field.

    Hope this helps.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have thousands of HTML files to process using Groovy/Java and I need to
this is what i have right now Drawing an RSS feed into the php,
I have this code to decode numeric html entities to the UTF8 equivalent character.
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
This could be a duplicate question, but I have no idea what search terms
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I have a text area in my form which accepts all possible characters from
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
I'm new to using the Perl treebuilder module for HTML parsing and can't figure

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.