CAML Query SharePoitn Calendar List Fails


#1

Hello,

I am trying to query a calendar list to get all events created within a date range. Every time The workflow starts, It is terminated with the following message.

System.Activities.Statements.WorkflowTerminatedException: Cannot complete this action. Please try again.

I think it has something to do with the list type (calendar). I have tested same query on regular list without issue. Here is my Query.

[%Parameter: Start Date%][%Parameter: End Date%]

Any help you could provide would be greatly appreciated!


#2

Hi,
Thank you for your message.

You may use this CAML query for getting all events created within a date range:

<View Scope="RecursiveAll"><Query><Where><And><Geq><FieldRef Name='Created' /><Value Type='DateTime'>2017-09-4T12:00:00Z</Value></Geq><Leq><FieldRef Name='Created' /><Value Type='DateTime'>2017-09-6T12:00:00Z</Value></Leq></And></Where></Query><ViewFields><FieldRef Name="Created" /></ViewFields></View>

Also, you may use this CAML query for getting all events which must occur within the specified period:

<View Scope="RecursiveAll"><Query><Where><And><Geq><FieldRef Name='EventDate' /><Value Type='DateTime'>2017-09-4T12:00:00Z</Value></Geq><Leq><FieldRef Name='EventDate' /><Value Type='DateTime'>2017-09-6T12:00:00Z</Value></Leq></And></Where></Query><ViewFields><FieldRef Name="EventDate" /></ViewFields></View>

Please pay attention to the time format in the CAML query.

By the way, you missed a tag in your example.

Best regards
Evgeniy Kovalev
Plumsail Team