0

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?

  • 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
1

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

0

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.