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

In my SharePoint JavaScript code, I am retrieving items from a list in my SP 2010 environment. I used a camel query to download specific fields. One of the fields was created by (person who created the item). When I loop through the items, I get the value of the created by field, and if I try to insert it into the dom, it says [object Object].

So I think there is a method I need to call on that object how I don't know what it is. I just want to get the display name from it as a string.

Does anyone know how?

share|improve this question
    
Can we see some of your code? Perhaps it is an spuserobject and you need to get the name property. var user = yourobject.Name ? –  BlueBird May 17 '13 at 19:52
    
Well I am getting the field using the column name Author. Also is there a way using any developer tools, to see what the datatype of this object is? –  omega May 17 '13 at 20:20

2 Answers 2

I got it, you need to use this method .get_lookupValue().

share|improve this answer

You need to call the right field...

    function findItems()
{
    var soapEnv =   "<soap:Envelope xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/'> <soap:Body>" + 
                    "<GetListItems xmlns='http://schemas.microsoft.com/sharepoint/soap/'>" +
                        "<listName>listNameHere</listName>" +
                        "<query> <Query> <Where>" +
                            "<Eq> <FieldRef Name='Assignee'/> <Value Type='Text'>" + variableName+ "</Value> </Eq>" +
                        "</Where> </Query> </query>" +
                        "<viewFields> <ViewFields> <FieldRef Name='Title' /> </ViewFields> </viewFields>" +
                        "<rowLimit>99999</rowLimit>" +
                        "<queryOptions xmlns:SOAPSDK9='http://schemas.microsoft.com/sharepoint/soap/' > <QueryOptions/> </queryOptions>" + 
                    "</GetListItems>" +
                "</soap:Body> </soap:Envelope>";
    $.ajax({
    url: "/_vti_bin/lists.asmx",
    type: "POST",
    dataType: "xml",
    data: soapEnv,
    complete: ProcessListItems,
    contentType: "text/xml; charset=\"utf-8\""
    });
}

function ProcessListItems(xData, status) {
    var createdBy;

    $(xData.responseXML).find("z\\:row").each(function () {
        createdBy= $(this).attr("ows_Author");
        alert(createdBy);
    });
}

The createdBy variable at the end, for example, will be the person who created the item. ows_Editor should be the last "Modified By" person

share|improve this answer
    
I am coding it different, I am doing it like the examples from msdn.microsoft.com/en-us/library/jj163201.aspx. –  omega May 17 '13 at 18:45

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.