0

I'm using spservices in SharePoint 2010 to get items from a list, and a want to retrieve all items from this year but i don't get anything. This Year column is a calculated type from the created column

        $().SPServices({
            operation: "GetListItems",
            async: false,
            listName: "{list guid}", 
            viewName: "{view guid}",
            CAMLViewFields: "<ViewFields><FieldRef Name='Year' /></ViewFields>",
            CAMLQuery: "<Where><Eq><FieldRef Name='Year' /><Value Type='Calculated'>2016</Value></Eq></Where>",
            completefunc: function (xData, Status) {
                        $(xData.responseXML).SPFilterNode("z:row").each(function() {
                            var liHtml =$(this).attr("ows_Title");
                            var Year += $(this).attr("ows_Year");
                        });

                }
        });

I test this with a different type of column and its working fine, If you can help me a really appreciate

  • Is Year column return data type is number or text? – Dikesh Gandhi Nov 23 '16 at 12:39
  • Single line of text, must be number ? – user3704742 Nov 23 '16 at 12:43
0

In the CAML query the Value Type you have specified is 'Calculated'. However, it should be the resulting Type of that calculated column.
So, if the resulting value is Single line of Text, it should be Text, if its a Number, it should be Number.
You need to change your CamlQuery line of code to below:

        CAMLQuery: "<Where><Eq><FieldRef Name='Year' /><Value Type='Text'>2016</Value></Eq></Where>",

Refer this blog where the blogger faced the same issue.

0

You need to add your <FieldRef Name='Ano' /> in view fields, If you are using in filter...

Also check what is value of status and response xml in completefunc.

  • but, how to extract the final value from the calculatedcolumn field and assign it to a string ? – SaMolPP Apr 10 '18 at 14:30

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.