0

I have a section of my code where I am retrieving a list item using SPServices GetListItems.

When pulling back the data for use I a missing one of my fields which I need for the display to work properly. The field is in the default view and I can see the field in the response text of the promise but cannot find it in the responseXML. The field itself is a Multiple Line of Text Plain Text field.

Here is the section of code that is failing

    var spPromise = $().SPServices({
        webURL  :   "/sites/rc/cas/",
        operation: "GetListItems",
        CAMLViewFields: "<ViewFields Properties='True' />",
        CAMLQuery: camlQuery ,
        listName: "Assessment Process",
        CAMLQueryOptions: "<QueryOptions><ExpandUserField>True</ExpandUserField></QueryOptions>",

    });

    spPromise.done(function() {
        console.log(spPromise);
        var procs =  $(spPromise.responseXML).SPFilterNode("z:row").SPXmlToJson({
                                                        includeAllAttrs: true,
                                                        removeOws: true,
                                                        sparse: false });
     });

I am returning the rest of the data In spPromise.responseText the field is there ows_Process_x0020_Comment='TEST'

I can find the field when running the rest query

    var thisUrl = "***Omitted***/sites/rc/cas";
    thisUrl += "/_vti_bin/listdata.svc/" 
    thisUrl += "AssessmentProcess(" + id + ")";     $.ajax({
        url:        thisUrl,
        method :    "GET",
        headers:    {"Accept" : "application/json; odata=verbose" },
        success:    function (data) {
            console.log(data);
        },
        error:      function (data) {
            console.log(data);
        }
    });

but don't really want to be rewriting the rest of my code to handle this

I have also tried looking for the attribute directly in the xml and returning all of the attributes in z:row but with no luck.

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

            $.each(this.attributes, function(i, attr) {
                var name = attr.name;
                var value = attr.value;

                console.log("Name:   " + name + "  :  Value:   " + value);
            });


            proc.Process_x0020_Comment = $(this).attr('ows_Process_x0020_Comment');
        });

I guess I could pull this data out of the responseText but would prefer to get this working without having to resort to anything like that.

Has anyone seen anything like this before or have any ideas on what might be going wrong as this has stumped me for about half a day now.

1 Answer 1

0

Here is an attempt. Have you tried selecting the column itself using the view fields option? Example:

var viewFields =    "<ViewFields>"+
                        "<FieldRef Name='ID'/>"+
                        "<FieldRef Name='Title'/>"+
                        "<FieldRef Name='Page'/>"+
                        "<FieldRef Name='Sub_x0020_List_x0020_Name'/>" +
                        "<FieldRef Name='Redirect_x0020_URL'/>"+
                    "</ViewFields>";
$j().SPServices({
    operation: "GetListItems",
    async: false,
    listName: listID,       //ID of the list
    CAMLQuery: query,
    CAMLViewFields: viewFields,
    completefunc: function (xData, Status) { ...

Here, I specifically selecting only the columns I want. Try this by targeting the columns you need for your code and let me know if that does trick.

1
  • Thanks @kyle-rogers-brodeur for the idea (a good one) but I'm afraid that it didn't work for me. I still ended up with the field missing. For now I have just parsed the responseText to get the field I am after and added it to the JSON. Aug 16, 2018 at 8:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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