Creating a weekly recurring event on SharePointOnline using OData query: A step-by-step guide

In the process of developing an internal network using SharePoint online and OData for REST requests, I encountered a challenge when trying to create recurring events. While single events are created successfully, recurrent events seem to be causing some trouble.

After executing the 'add' function, the event is added to the calendar but only as a singular occurrence.

Below is the recurrence string that I have been using:

<recurrence>
    <rule>
        < firstDayOfWeek > su < /firstDayOfWeek>
        < repeat >
            <weekly tu='TRUE' we='TRUE'  weekFrequency= '1'/>
        < /repeat>
        < windowEnd >2018-08-22T09:12:26Z< /windowEnd > 
    < /rule>
</recurrence >

And here is the query that includes the creation of recurring events:

if (newItem["Recurrent"]) {
    return new Web(`${this.baseUrl}`)
        .lists
        .getByTitle(this.baseList)
        .items
        .add({
            "Languages_Active": true,
            "Title": newItem["Title"],
            "Languages_PT": true,

            ["Title_" + language]: newItem["Title"],
            ["Description_" + language]: newItem["Description"],
            'Preferences': newItem["Preferences"],
            'fRecurrence': newItem["Recurrent"],
            'FromLocation': newItem["FromLocation"],
            'ToLocation': newItem["ToLocation"],
            'StopPoint': newItem["StopPoint"],
            'Seats': newItem["Seats"],
            'PrivateCar': newItem["PrivateCar"],

            'EventDate': newItem["StartDate"],
            'EndDate': newItem["EndDate"],

            //recurrent event fields
            'EventType': 1,
            'RecurrenceData': recurrenceString,
            'fAllDayEvent': false,
            'TimeZone': 0,
        })
        .then(createResult => {
            this.count(listName, country);
            this.home(refresh, listName, language, country);
        });

Despite successfully creating items, there seems to be an issue with one particular field causing the loader to fail in loading calendar events.

The use of custom recurrence patterns is restricted by SharePoint, leading me to utilize 'spEventsHelpers' for handling recurrent events. Is it possible to switch from custom recurrence to a simple weekly pattern?

Furthermore, why am I unable to see the pattern correctly? I've spent hours trying to identify the problem without success. If you have any insight or similar experiences, please share them. Thank you in advance for your assistance!

Answer №1

SharePoint encounters issues when trying to interpret the XML content within the RecurrenceData field due to excessive spaces that render the syntax invalid. Below are examples illustrating this problem:

< firstDayOfWeek > su < /firstDayOfWeek>   //Incorrect         
<firstDayOfWeek>su</firstDayOfWeek>        //Correct

<weekly tu='TRUE' we='TRUE'  weekFrequency= '1'/> //Incorrect
<weekly tu='TRUE' we='TRUE' weekFrequency='1'/>   //Correct

To fix this issue, it is advisable to review the code responsible for generating the XML in question and remove any unnecessary spaces. The corrected version should resemble the following structure:

<recurrence><rule><firstDayOfWeek>su</firstDayOfWeek><repeat><weekly tu='TRUE' we='TRUE' weekFrequency='1'/></repeat><windowEnd>2018-08-22T09:12:26Z</windowEnd></rule></recurrence>

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Avoiding errors during radio value changes when loading a component in Angular

I need assistance with setting a date using radio buttons. I encountered an error when I tried to change the value while the component was loading. html.component.html ... <div> <input type="radio" name="period" [checked]= ...

The incorrect sequence of Angular/Protractor functions is causing issues within the tests

Trying to extract the values from a column in a grid and compare them before and after sorting can be tricky. I have two functions set up for this task - one to retrieve the initial column values, and another to check the order post-sorting. However, there ...

Utilizing Typescript: Ensuring an array includes only specified values from an enum through strict enforcement

In my Angular application, I have an HTTP service that returns the allowed accesses for a specific user. The response structure is as shown below:- { "accessId": 4209318492034, "folderPath": "data/sample_folder/", ...

Error in Typescript occurrence when combining multiple optional types

This code snippet illustrates a common error: interface Block { id: string; } interface TitleBlock extends Block { data: { text: "hi", icon: "hi-icon" } } interface SubtitleBlock extends Block { data: { text: &qu ...

I am having trouble with the TypeScript compiler options not being detected in Visual Studio 2015

After creating an ASP.NET 5 Empty Website project in Visual Studio 2015, I set up a tsconfig.json file with the following settings: { "compilerOptions": { "noImplicitAny": false, "noEmitOnError": true, "removeComments": false ...

Nest Js file uploads encountering issues when used in conjunction with JavaScript FormData functionality

I'm encountering some difficulties in parsing a request sent from the front-end using FormData. Below is an example request generated from Postman for Axios in node.js. Interestingly, when I use the same request in the Postman app, it functions as int ...

Encountering an issue while trying to compile my Angular 6 project - an ERROR keeps

Upon initiating my project with ng serve, I encountered a troublesome error. Despite updating my TypeScript, the issue persisted. Here is the detailed error message: ERROR in node_modules/@types/node/assert.d.ts(3,68): error TS1144: '{' or ...

Tips for creating basic Jasmine and Karma tests for an Angular application to add an object to an array of objects

I have developed a basic Angular project for managing employee data and I'm looking to test the addProduct function. Can someone guide me on how to write a test case for this scenario? I am not using a service, just a simple push operation. Any assist ...

What is the best way to align an image to the right of an ion-label?

I'm struggling to place a colored WhatsApp image on the right side of an ion-label. Here's what I have so far: <ion-row> <ion-col size="10"> <ion-label position="floating">Contato 1* </ion-label> </ion-col&g ...

Angular: Implementing a Click Event in a Component

I am facing an issue with two components that share the same child but are initialized with different inputs. After initializing the inputs in the ngOnInit of the child component, I noticed that when I click on one of the components for the first time, th ...

Testing Angular: How to Unit-test HttpErrorResponse with custom headers using HttpClientTestingModule

In the code snippet below, I am attempting to find a custom header on error: login(credentials: Credentials): Observable<any> { return this.http.post(loginUrl, credentials) .pipe( catchError((httpErrorResponse: HttpErrorRespo ...

What steps can be taken to ensure that a second Pinia plugin waits for the completion of the

I am currently developing a Vue application with Pinia as the state manager. I have created two plugins - one for authentication and another to set up my API instance. The second plugin relies on the token obtained from the first plugin. Upon analyzing th ...

Incorporate chat functionality into Angular using an embedded script

Recently, I encountered an issue with inserting an online chat using a Javascript script into my website. My initial plan was to add it directly to my app.component.html, but unfortunately, it didn't display as expected. I'm now exploring option ...

When the column is empty, I want to ensure that the hyphen is retained. I have attempted using ngIf, but it

I am seeking assistance on adding a hyphen to a column when no data is received from the service. The code I am currently using does not seem to be working as expected. {{element.j1RangeLs | date :'dd-MMM-yyy' }} <br> <span *ngIf = "j1R ...

Managing the back button in Nativescript-Angular to toggle visibility

Struggling to toggle the visibility of an element in response to the back button event. <ActionItem icon="~/images/menu_3_dots.png" ios.position="right" android.position="right" *ngIf="isActionItemVisible"></ActionItem> construc ...

Mistakenly importing the incorrect version of Angular

While working on my Angular 1 app in typescript, I faced an issue when importing angular using the following syntax: import * as angular from 'angular'; Instead of importing angular from angular, it was being imported from angular-mocks. Thi ...

Guide to deploying a multilingual Angular application on Google App Engine

After successfully building my Angular 8 application using the angular/cli and incorporating i18n multilanguage support for English, Spanish, and French translations, I find myself with a new challenge. For each language version of my app that I build, it ...

Getting an error when running forEach() on div elements in JavaScript

I am facing an issue with changing the height of divs in an array. Even though I am able to log the names of the divs correctly, when I try to set their height, I encounter a "this is undefined" error message in the console. Despite successfully logging a ...

An error of unknown token U was encountered in the JSON data starting at position 0

I am facing an issue with my MEAN Stack development. Currently, I have an Angular Form set up with proper values to create a company in the database using Node Express on the backend. However, I keep encountering an error stating that the JSON in Node is ...

When executing npm run build for production, the resulting build does not include distribution for

I am encountering an issue with my Angular project, specifically during the build process. After running ng build, the dist folder is created with the correct build. However, when I run the command: ng build --prod it generates the production build as e ...