I am using a SPFx react web-part to get the events from calendar.
I am expanding the calendar events however could not able to get the Category
column.
Here is the code I am using:
public getEvents(listTitle: string): Promise<Array<any>> {
return new Promise<Array<any>>((resolve: any, reject) => {
let oWeb = sp.web;
let todayDate = new Date().toISOString();
//filter("EventDate ge '"+todayDate+"'").
sp.web.lists.getByTitle(listTitle).select('Id,Title').renderListDataAsStream({
OverrideViewXml: `
<QueryOptions>
<ExpandRecurrence>TRUE</ExpandRecurrence>
</ViewFields>
</QueryOptions>
`,
}).then((items: any[]) => {
let arrItems = []
if (items["Row"].length > 0) {
items["Row"].forEach(element => {
if (new Date(element.EventDate) > new Date()) {
if (arrItems.length <= 4)
arrItems.push(element)
}
});
}
resolve(arrItems)
}).catch((error) => {
console.log("Error while getting event list items ", error);
reject(error);
});
});
}