1.3.2
Please specify what version of the library you are using: [ 1.3.2 ]
Please specify what version(s) of SharePoint you are targeting: [ SharePoint Online ]
I am trying to get Events from Calendar along with Recurring Events using getItemsByCAMLQuery with QueryOptions. It is returning Parent Recurring Event but not expanidng it. If the event marked as Daily, expecting to show events data for daily. Is it an issue or I am any doing anything wrong?
Below is my code
const xml = <View> \
<ViewFields> \
<FieldRef Name=Title/> \
<FieldRef Name=EventDate/> \
<FieldRef Name=EndDate/> \
<FieldRef Name=Location/> \
<FieldRef Name=Description/> \
<FieldRef Name=fRecurrence/> \
<FieldRef Name=RecurrenceData/> \
<FieldRef Name=fAllDayEvent/> \
<FieldRef Name=ID/> \
</ViewFields> \
<Query> \
<Where> \
<DateRangesOverlap> \
<FieldRef Name=EventDate/> \
<FieldRef Name=EndDate/> \
<FieldRef Name=RecurrenceID/> \
<Value Type=DateTime> \
<Today /> \
</Value> \
</DateRangesOverlap> \
</Where> \
<OrderBy> \
<FieldRef Name=EventDate/> \
</OrderBy>\
</Query> \
<QueryOptions> \
<CalendarDate> + new Date().toISOString() + </CalendarDate>\
<ExpandRecurrence>TRUE</ExpandRecurrence>\
<RecurrencePatternXMLVersion>v3</RecurrencePatternXMLVersion>\
<RecurrenceOrderBy>TRUE</RecurrenceOrderBy>\
<ViewAttributes Scope=RecursiveAll/>\
</QueryOptions>\
<RowLimit>10</RowLimit> \
</View>;
let q: pnp.CamlQuery = {
ViewXml: xml,
};
pnp.sp.web.lists.getByTitle(LIST_NAME).items.filter(dateFilter).get().then(
res=>{
console.log('Direct Method..');
console.log(res);
}
);
You also need to have this in the Query Options in the CAML:
<ExpandRecurrence>TRUE</ExpandRecurrence>
See my post Retrieving Expanded Calendar Events with REST vs. SOAP
You also need to have this in the Query Options in the CAML:
<ExpandRecurrence>TRUE</ExpandRecurrence>
See my post Retrieving Expanded Calendar Events with REST vs. SOAP
Hi Sympmarc
Thanks for your reply. I have added ExpandRecurrence in the QueryOptions but still it is not expanding. And I came across your post even before also. I am not using SpServices library and looking for options in Sp-Pnp-Js. As your post was belong to July 2015, thought there will be some update.
Recurrent events is the pain in API, no support in OData. If getItemsByCAMLQuery doesn't work, you can try renderListData and renderListDataAsStream, e.g.:
import { sp } from '@pnp/sp';
sp.web.lists.getByTitle('Calendar')
.renderListDataAsStream({
OverrideViewXml: `
<QueryOptions>
<ExpandRecurrence>TRUE</ExpandRecurrence>
</QueryOptions>
`
})
.then(console.log)
.catch(console.log);

UPD: By default renderListDataAsStream does it. So start with renderListDataAsStream and find the corresponding caml or override which works for the usecase.
sp.web.lists.getByTitle('Calendar').renderListDataAsStream({}).then(console.log);
My assumption on OverrideViewXml in the previous sample was a false positive.
UPD: By default
renderListDataAsStreamdoes it. So start withrenderListDataAsStreamand find the corresponding caml or override which works for the usecase.sp.web.lists.getByTitle('Calendar').renderListDataAsStream({}).then(console.log);My assumption on OverrideViewXml in the previous sample was a false positive.
Hi koltyakov,
Thanks for the reply.
My use case is to retrieve the Upcoming events from the calendar with pagination.
Below are my findings..
const xml = <View> \
<Query> \
<Where> \
<DateRangesOverlap> \
<FieldRef Name=EventDate/> \
<FieldRef Name=EndDate/> \
<FieldRef Name=RecurrenceID/> \
<Value Type=DateTime> \
<Today /> \
</Value> \
</DateRangesOverlap> \
</Where> \
<OrderBy> \
<FieldRef Name=EventDate/> \
</OrderBy>\
</Query> \
<RowLimit>10</RowLimit> \
</View>;
sp.web.lists.getByTitle(LIST_NAME).renderListDataAsStream({OverrideViewXml: xml, Paging:'Paged=TRUE&RowLimit=5'}).then(
res=> { console.log(res); })
Looking for work around. If I find anything update here..
Going to close this as it doesn't appear to be an issue with the library. If there is still an issue here I missed please open a new issue and reference this one explaining what is not working and we can take a look. Thanks!
UPD: By default
renderListDataAsStreamdoes it. So start withrenderListDataAsStreamand find the corresponding caml or override which works for the usecase.sp.web.lists.getByTitle('Calendar').renderListDataAsStream({}).then(console.log);My assumption on OverrideViewXml in the previous sample was a false positive.
How can I selecct the column..i used this but not able to find the Category column in it.
Most helpful comment
UPD: By default
renderListDataAsStreamdoes it. So start withrenderListDataAsStreamand find the corresponding caml or override which works for the usecase.My assumption on OverrideViewXml in the previous sample was a false positive.