basquang™ on clouds

September 21, 2010

SPServices: Using jQuery to auto fill current user information in SharePoint 2010

Filed under: SharePoint — basquang @ 4:08 AM

Using following script in your page by SharePoint Designer or Content Editor WP

<script language="javascript" src="/TimeSheet/jQuery%20Libraries/jquery-1.4.2.min.js" type="text/javascript"></script>
<script language="javascript" src="/TimeSheet/jQuery%20Libraries/jquery.SPServices-0.5.4.min.js" type="text/javascript"></script>
<script language="javascript" type="text/javascript">
$(document).ready(function() {
    var userDepartment = $().SPServices.SPGetCurrentUser({
        fieldName: "Department"
    });
    $("input[Title='Department']").val(userDepartment);    
});
</script>

In this script, we auto fill Department textbox by department of current user.

Reference

Advertisements

4 Comments »

  1. It’s going to be finish of mine day, however before end I am reading this impressive article to increase my knowledge.

    Comment by online winkel — April 9, 2013 @ 1:28 AM | Reply

  2. Thanks for sharing your thoughts. I really appreciate your efforts
    and I am waiting for your next post thank you once again.

    Comment by google referencement site — July 27, 2013 @ 12:32 PM | Reply

  3. I wanted to auto populate Manager Name and custom field created in my User Profile.
    Any Suggestion??
    How to do it..

    Comment by Sabina Ansari — October 3, 2013 @ 7:47 PM | Reply


RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Create a free website or blog at WordPress.com.

%d bloggers like this: