2

Pretty new to CAML queries, but trying to query a list based on Status = Completed and a date range.

It is throwing the following error "Unexpected Error: One or more field types are not installed properly. Go to the list settings page to delete these fields. Microsoft.SharePoint"

Status and Created are both system columns, so 99.9% sure I have the Field Names correct I have tested the query without the Date Range and it runs as expected, so I think my problem is somewhere in between <geq> and </leq> From what I have read, Created expects time to follow date. Query is below, any help would be greatly appreciated.

    <Where>   
    <And>                               
    <And>    
    <Eq><FieldRef Name="Status" />Value Type="Choice">Completed</Value></Eq> 
    </And>          
    <Geq>         
    <FieldRef Name="Created" /><Value IncludeTimeValue="TRUE"    
    Type="DateTime">2013-07-02T00:00:01Z</Value>
    </Geq>
    <Leq>              
    <FieldRef Name="Created" /><Value IncludeTimeValue="TRUE" 
    Type="DateTime">2013-07-02T23:59:59Z</Value>
    </Leq>
    </And> 
    </Where>
4

You've got a missing < before your first Value> and a misplaced <And> between the <Eq> and <Geq> that should be after the </Geq>.

<Where>
    <And>                               
        <And>    
            <Eq><FieldRef Name="Status" /><Value Type="Choice">Completed</Value></Eq>      
            <Geq>         
                <FieldRef Name="Created" />
                <Value IncludeTimeValue="TRUE" Type="DateTime">2013-07-02T00:00:01Z</Value>
            </Geq>
        </And>
        <Leq>              
            <FieldRef Name="Created" />
            <Value IncludeTimeValue="TRUE" Type="DateTime">2013-07-02T23:59:59Z</Value>
        </Leq>
    </And> 
</Where>

Also, this may be better:

<Where>
    <And>                               
        <Eq><FieldRef Name="Status" /><Value Type="Choice">Completed</Value></Eq>      
        <Eq>         
            <FieldRef Name="Created" />
            <Value IncludeTimeValue="FALSE" Type="DateTime">2013-07-02T00:00:00Z</Value>
        </Eq>
    </And>
</Where>
  • 1
    It is also possible to use <Value Type="Text">Completed</Value> in query, no need to use choice if there is no multichoice column – Tim Aug 16 '13 at 12:53
  • Stuart, Thanks so much. No more errors, but this CAML query is part of a web part that performs a copy between libraries based on Completed Status and the date range. I am testing this in a Dev environment and I have had to use another date field for the range as "Created" is defaulted to the date I uploaded all the test items. – Carl Frank Aug 16 '13 at 16:04
  • Anyway, I have no issue specifying the other column, (it is named Alerts Received) but when I try and just specify items from 7/2/13 0:00:00 to 7/2/13 23:59:59 or your second example, everything that copies over to the destination library is for (Alert Received) 7/3/13, not 7/2/2013. Thoughts? – Carl Frank Aug 16 '13 at 16:05
  • I had a similar problem with timezones a while back, but the detail of the cause escapes me at the moment. – Stu Pegg Aug 16 '13 at 17:33

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.