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 get the details of the list in sharepoint by using the jquery in content editor webpart. I created one .js file and I made a link in the content editor webpart. This is working awesome. but the problem is, when I query the list which doesn't have any lookup column all columns are coming in the resultant xml. but if we query the list which contains lookup it doesn't give me the lookup column details at all. Why this is happening. I tried to get the details of City list which have the lookup column to Countries list by following.

<script type="text/javascript" src="_layouts/jquery-1.8.2.js"></script>
<script type="text/javascript" src="_layouts/jquery.SPServices-0.7.1a.min.js"></script>
<script type="text/javascript">
    $(document).ready(function() {
        var soapEnv = "<soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/'> \
                <soapenv:Body> \
                     <GetListItems xmlns='http://schemas.microsoft.com/sharepoint/soap/'> \
                        <listName>City</listName> \
                        <viewFields> \
                            <ViewFields> \
                               <FieldRef Name='Title' /> \
                           </ViewFields> \
                        </viewFields> \
                    </GetListItems> \
                </soapenv:Body> \
            </soapenv:Envelope>";
        $.ajax({
            url: "http://sp2010:8080/personal/Inclusions/_vti_bin/lists.asmx",
            type: "POST",
            dataType: "xml",
            data: soapEnv,
            complete: processResult,

            error : callError,
            contentType: "text/xml; charset=\"utf-8\""
        });
    });
    function processResult(xData, status) {
    alert(xData.responseText);
        $(xData.responseXML).find("z\\:row").each(function() {
            var liHtml = "<li><a href='#'>" + $(this).attr("ows_Title") + "</a></li>";
             $("#tasksUL").append(liHtml);
        });   }
    function callError(jqXHR, textStatus, errorThrown){   alert(errorThrown); }
</script>
</script>

    <marquee direction='up' behavior='scroll' style="height:100px" onmouseover= "this.stop();" onmouseout="this.start();"><ul id="tasksUL"/></marquee>

The resultant xml is

<z:row ows_Title='Hyderabad' ows_MetaInfo='1;#' ows__ModerationStatus='0' ows__Level='1' ows_ID='1' ows_UniqueId='1;#{ADA568FB-640B-4A46-8A5F-C03E47A36393}' ows_owshiddenversion='1' ows_FSObjType='1;#0' ows_Created='2012-10-22 04:08:03' ows_PermMask='0x7fffffffffffffff' ows_Modified='2012-10-22 04:08:03' ows_FileRef='1;#personal/Inclusions/Lists/City/1_.000' />

I am just showing here row only. Will lookup column doesn't come in our result?

share|improve this question
2  
Mihir, In the <ViewFields><FieldRef Name='Title' /></ViewFields>, you have mentioned only Title that is why only title is returned.. Put the lookup column name too, as <FieldRef Name='Countries' /> - I am not sure if this is correct answer :) –  Arsalan Adam Khatri Oct 25 '12 at 15:34
add comment

1 Answer

up vote 0 down vote accepted

Finally I changed as below.

var soapEnv = "<soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/'> \
                <soapenv:Body> \
                     <GetListItems xmlns='http://schemas.microsoft.com/sharepoint/soap/'> \
                        <listName>Events</listName> \
                        <viewFields> \
                            <ViewFields> \
                               <FieldRef Name='Title' /> \
                               <FieldRef Name='Due_x0020_Date' /> \
                           </ViewFields> \
                        </viewFields> \
                    </GetListItems> \
                </soapenv:Body> \
            </soapenv:Envelope>";
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.