Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I am trying to find the Author Name(created by) for a given Item Id using the SP Client context in SharePoint 2010.

Below the code snippet

var ctx = new SP.ClientContext.get_current();

        //this.web = ctx.get_web().get_lists().getByTitle(;

        var query = new SP.CamlQuery();

        var queryStr = "<View><Query><Where><Eq><FieldRef Name=\'Series\' /><Value Type=\'Choice\'>Sample</Value></Eq></Where></Query></View>";

        alert( queryStr );

        query.viewXml = queryStr;

        var list = ctx.get_web().get_lists().getByTitle('PKS Podcasts');

        listItems = list.getItems(query);

        ctx.load(listItems);

        ctx.executeQueryAsync(Function.createDelegate(this, this.onSuccess), Function.createDelegate(this, this.onFail));

    }
    function onSuccess(sender, args) {      
          var listEnumerator = listItems.getEnumerator();
          while (listEnumerator.moveNext()) {
           alert("Item containing ‘announce’ found! \nTitle: " + listEnumerator.get_current().get_item("Author"));                      
          } 

    }
    function onFail(sender, args) {
        alert('failed to get list. Error:'+args.get_message());
    }       

But it is returning the object and not able to get the Author name...is there a way to find the same?

share|improve this question
2  
found a way of doing it... alert("Item containing ‘announce’ found! \nTitle: " + listEnumerator.get_current().get_item("Author").get_lookupValue()); –  Karthikeyan Jun 16 '11 at 20:12
1  
Can you please move your comment into an answer? Then you can mark the question as answered. Thanks! –  Alex Angas Aug 26 '11 at 4:55
add comment

1 Answer

Solution moved from comment:

alert("Item containing ‘announce’ found! \nTitle: " + 
    listEnumerator.get_current().get_item("Author").get_lookupValue());
share|improve this answer
add comment

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.