How to prevent overlapping appointments in Scheduler?

Answer:

We can avoid the overlapped appointments by using IsSlotAvailable public method which helps to check whether the given time slots already exist in events. So, based on the Boolean value we can prevent the event using Cancel argument of OnActionBegin event.

" OnActionBegin="OnActionBegin">

@code {

SfSchedule ScheduleObj;

List DataSource = new List

{

new AppointmentData { Id = 1, Subject = "Meeting", StartTime = new DateTime(2020, 1, 6, 9, 30, 0) , EndTime = new DateTime(2020, 1, 6, 11, 0, 0),

RecurrenceRule = "FREQ=DAILY;INTERVAL=1;COUNT=5", RecurrenceException = "20200107T043000Z,20200109T043000Z" }

};

public async Task OnActionBegin(ActionEventArgs args)

{

bool Availability = true;

if (args.AddedRecords.Count() > 0)

{

Availability = await ScheduleObj.IsSlotAvailable(args.AddedRecords[0]);

}

args.Cancel = !Availability; // To avoid appointments overlapping.

}

...

}



2 Replies

RJ Rahul Jain October 18, 2022 06:29 AM UTC

I have tried this solution also but that is not working completely,


When I update event in same day with different time that time that is working,


But this solution is not working for other events.


Please let me know , How to prevent all types of events.


I want only one appointment on a datetime .


Please let me know, I am waiting for Response.


Thank you -


Rahul Jain



RV Ravikumar Venkatesan Syncfusion Team October 19, 2022 11:46 AM UTC

Hi Rahul,


We have created a new forum for your query “I want only one appointment on a DateTime” for easy follow-ups. So, we suggest you follow the below forum for your new query.


https://www.syncfusion.com/forums/178303/i-want-only-one-appointment-on-a-datetime-from-forum-162252?reply=SfYyvr


Regards,

Ravikumar Venkatesan


Loader.
Up arrow icon