SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I would have a list that i am working on and my goal is to load the users name to a text box from active directory when the user click on add new item... Can anyone help me with that?

share|improve this question

You can use the SharePoint Javascript API

    var siteUrl = '/sites/MySiteCollection';

function retrieveAllListProperties() {

var clientContext = new SP.ClientContext(siteUrl);
var oWebsite = clientContext.get_web();
this.collList = oWebsite.get_lists();


clientContext.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceeded), Function.createDelegate(this, this.onQueryFailed));

function onQuerySucceeded() {

var listInfo = '';

var listEnumerator = collList.getEnumerator();

while (listEnumerator.moveNext()) {
    var oList = listEnumerator.get_current();
    listInfo += 'Title: ' + oList.get_title() + ' Created: ' + oList.get_created().toString() + '\n';

function onQueryFailed(sender, args) {
alert('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace());

You can use the SP.ClientContext.CurrentUser property and then set the text to the corresponding textbox with the value you retrieved. Below are the references you will need. The example specified is just demonstrating how to use the SharePoint Javascript OM that OM has access to SharePoint Security Context which in turn gives you the current user information.

<script type="text/ecmascript" src="/_layouts/SP.Core.js" />
<script type="text/ecmascript" src="/_layouts/SP.Debug.js" />
<script type="text/ecmascript" src="/_layouts/SP.Runtime.Debug.js" />
share|improve this answer
Awesome thank you very much! – TheEisdame Oct 9 '12 at 13:59
No problem hope it solves your problem. If it does please click answer buddy :) – Joseph D Surgeon Oct 9 '12 at 14:00

Your Answer


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.