5

I have a calculated column that stores the calculated date value.

When I apply the CAML query, it does not return any row even if the record exists.

1
  • Hi Mansi. I know it has been a while since you posted this question but I recently had a scenario similar to yours. The only way I solved it was to first load ALL the list items within the list into a ListItemCollection specifying the fields making up the Calculated column in the <ViewFields>, and then I used LINQ on all the ListItemCollection whilst at the same time re-creating the Calculated column within the query. I could post an answer with more detail if this is still a problem for anyone or if anyone is interested to know more about my "solution" Aug 1, 2017 at 7:10

3 Answers 3

1

You have to use Value Type equals your OutputType rather than Calculated in CAML query.

// This will not work >> <Value Type='Calculated'>my value</Value>

// Following will work
<Where>
  <Contains>
    <FieldRef Name='FullName' />
      <Value Type='Text'>my value</Value>
  </Contains>
</Where>

Read this link: CAML Query on Calculated Fields

1
  • 1
    I don't think this is correct. I had recreated this problem and Calculated fields never returned results for me, even if I was sure they existed within the list/library. Aug 1, 2017 at 7:06
0

This might be related to what you use as value type in your CAML. The type must be the return type of your calculation for example it might be 'Number'

0

I used the FieldInternalName instead of the custom name of the field to make the Ronak Patel's solution working.

Who could not make it work:

The caluclated SharePoint field also has FieldInternalName which is generated at the first time when the field is created.

Once the field is renamed then the FieldName is changing accordingly, but the FieldInternalName not. You can get the calc field FieldInternalName from the display form by F12 - developer tool selecting calculated field element td#SPFieldCalculated as this field type is not visible on the New or Edit Forms.

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.