0

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);
        });

     });
}
3
  • your caml query seems wrong, can you share the correct query ? Commented Sep 19, 2019 at 9:48
  • it is correct and getting the data also but not only the Category Column
    – Ramesh
    Commented Sep 19, 2019 at 10:20
  • I am also facing the same issue could you please help me if you found the any solution
    – anil kumar
    Commented Jun 11, 2020 at 17:40

1 Answer 1

0

Try Using your API call like:

// use odata operators for more efficient queries
sp.web.lists.getByTitle(listTitle).items.select("Id","Title","Category").get().then((items: any[]) => {
    console.log(items);
});
3
  • by this it will get the recurrent events
    – Ramesh
    Commented Sep 19, 2019 at 10:20
  • Sorry, I am not able to get you? Do you want to get the recurrent events? Commented Sep 19, 2019 at 10:23
  • Yes I would like to fetch the all events with recurrent items
    – Ramesh
    Commented Sep 19, 2019 at 10:30

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.