0

I have this problem: I want to query a list using Caml. Here is the query:

    <Where>
        <And>
            <Geq>
                <FieldRef Name="Next_x0020_Oil_x0020_Change_x002" />
                <Value Type="DateTime">
                    <Today />
                </Value>
            </Geq>
            <Leq>
                <FieldRef Name="Next_x0020_Oil_x0020_Change_x002" />
                <Value Type="DateTime">
                    <Today OffsetDays="+7"></Today>
                </Value>
            </Leq>
        </And>
    </Where>

The internal name of the column I want to use is: Next_x0020_Oil_x0020_Change_x0020_Date. I've checked it, it's correct.

However, as far as i know this name is too long and it's being cut to 32 charecters or: Next_x0020_Oil_x0020_Change_x002.

In the code I use the query list.GetItems(caml) and it appears to be ok, but when I try to iterate through the returned items it throws the exception.

One or more field types are not installed properly. Go to the list settings page to delete these fields.

Even more weird is that when I execute the query in the U2U caml Query Builder Tool, it does not show any errors and returns the exact rows that I need.

As far as I know there are no problems with the field types of the list. Even if there are, I don't know where to look. The exception does not give that kind of information and the logs are not very helpful either.

Any ideas?

1
  • Are you using c# or javascript? Did you properly set the viewfields property?
    – MdMazzotti
    Commented Mar 24, 2014 at 9:17

1 Answer 1

1

I found a way to fix it.

This query is part of 4 Caml queries. I execute them one by one. My mistake was that I used the same SPQuery object. I just changed the Query property. What I didn't know was that after the first execution the SPQuery object stores some configuration data for faster querying.You can not just change the Query property and expect it to work fine. It appears to work but makes changes to the logic and does not always return the items you need. After the 3-rd time it blew up completely.

The Solution:

Create a new SPQuery object every time you want to query a list.

Your Answer

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

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