1

I'm trying to get Data from SP List via SOAP.

It works for standard columns like "ows_Modified". But if I try to get Data from Column I created (example: "DogNames") in the SP List by myself, it doesn't work.

Could you please take a look. It seems like I've to make some modifications

function getSharepointListData (rightList) {

   var listName = rightList;

var soapEnv =
    "<soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/'> \
        <soapenv:Body> \
             <GetListItems xmlns='http://schemas.microsoft.com/sharepoint/soap/'> \
                <listName>"+listName+"</listName> \
                <viewFields> \
                    <ViewFields> \
                       <FieldRef Name='Author' /> \
                   </ViewFields> \
                </viewFields> \
            </GetListItems> \
        </soapenv:Body> \
    </soapenv:Envelope>";

$.ajax({
    url: "http:URL/_vti_bin/lists.asmx",
    type: "POST",
    dataType: "xml",
    data: soapEnv,
    complete: processResult,
    contentType: "text/xml; charset=\"utf-8\""
});

function processResult(xData, status) {

var j = 0;
var myArray = new Array();

$(xData.responseXML).find("z\\:row").each(function() {

    //var content = $(this).attr("ows_Modified");
     var content = $(this).attr("dogNames");


   myArray[j] = content;

    $("#tasksUL").append(content + '</br>');
   j++;

}); }}

Is it also possible somehow to count the columns in the list? For example to get information from Column 1, 2 ..... instead of the name.

Any help would be appreciated!!!

  • Did you try ows_dogNames? – Erin L Mar 17 '16 at 14:40
  • Version of SharePoint? – Nisarg Mar 17 '16 at 14:47
  • yes i tried with ows_dogNames. I get an Array with 12 "undefied" objects (12 rows in the list). Sharepoint 2010 – Jochen Schneider Mar 17 '16 at 14:56
  • Try including your custom field in the <ViewFields> section – Erin L Mar 17 '16 at 15:04
  • Have you considered using SPServices? Works on SP 2010 and easier to work with. spservices.codeplex.com/documentation – ova Mar 17 '16 at 15:32
1

Put this in an html file somewhere on your site and replace the SITE and listName values. Let me know what you get back.

<html><head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.SPServices/2014.02/jquery.SPServices.min.js"></script>
<script>
SITE = "http://sharepointsite/";

$(document).ready( function(){
    $().SPServices({
        webURL: SITE,
        operation: "GetListItems",
        listName: "dogNames",
        async: false,
        CAMLViewFields: "<ViewFields><FieldRef Name='Title' /><FieldRef Name='dogNames' /></ViewFields>",
        completefunc: function(xData, Status) {
            /***********************************Debugging******************************************************/
                var out = $().SPServices.SPDebugXMLHttpResult({
                node: xData.responseXML
                });
                $("#debug").html("").append("<b>This is the output from the GetList operation:</b>" + out);
            /***************************************************************************************************/
        }
    });

});
</script>
</head>
<body>
<div id="debug"></div>
</body>
</html>
0

I got it with SP Services. Thank you all for help!

var SITE = URL;
var myArray = new Array();
$(document).ready( function(){
    $().SPServices({
        webURL: SITE,
        operation: "GetListItems",
        listName: "dogNamesList",
        async: false,
        CAMLViewFields: "<ViewFields><FieldRef Name='dogNames' /></ViewFields>",
        completefunc: function(xData, Status) {

           $(xData.responseXML).SPFilterNode("z:row").each(function() { 

                var data = ($(this).attr("ows_dogNames"));

                var j = 0;

                myArray[j] = data;

                j++;


            });

        }
    });

});
  • Since you seem to have had a lot of help of the answers here, please at least upvote them :) – Robert Lindgren Mar 21 '16 at 9:37

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.