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

Using a 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 the Department textbox by the department of the current user.

Reference

This Post Has 0 Comments

  1. online winkel

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

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

  3. Sabina Ansari

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

Leave a Reply