22
Views
7
Comments
Solved
Duplicate condition with date, start time and end time
Question
Application Type
Reactive
Service Studio Version
11.54.51 (Build 63195)

Hi everyone,

I need some help to make condition for duplicate booking meeting room, the attribute entity is Date, Start Time and End Time.

The objective is to restrict staff members that booking the meeting room on the same date, start time and end time as other staff member that has already booked. I'm unsure how to enforce the condition for overlapping bookings by other staff within the same time frame. 


This is picture where I tried to make the condition for duplicate. So, at Data tab, under BookingDetail entity there are MeetingDetail,Date,StartTime and EndTime.



UserImage.jpg
Shriyash Dixit
Solution

@Syakirah

To achieve this you need to add a filter condition in the existing booking entity aggregate - 

DB_Date = InputParam_BookingDate and
((DB_StartTime <= InputParam_ endTime and DB_ EndTime >= InputParam_ startTime) or (DB_ StartTime < InputParam_ endTime and DB_ EndTime > InputParam_ startTime))

after that -check if the above aggregate  Isempty?
if Yes - allow to save 
if No - Do not allow for booking

This should work in your scenario

Cheers,
Shriyash Dixit

UserImage.jpg
Syakirah

Thank you so much, it worked. Thank you Shriyash

UserImage.jpg
Shriyash Dixit
2024-02-02 10-09-47
Mukesh Kumar Deva

Hi Syakirah,

I think you can do this by few methods, let me specify one method.

You can use one aggregate to fetch the all the booking first then you can use a calculated attribute in that aggregate to check whether the start date time entered by using the expression such as "BookingDetail.Startdatetime <= InputBookingDetail.StartDateTime and InputBookingDetail.StartDateTime <= BookingDetail.EndDateTime", this will give you true as output if the condition matches and you can repeat the same for the end date time.

After that you can use List Any server action to check any of the record in the aggregate is true in either of the 2 calculated attributes.

This can help you to avoid the duplicate entries, I think so. 

UserImage.jpg
Shriyash Dixit
Solution

@Syakirah

To achieve this you need to add a filter condition in the existing booking entity aggregate - 

DB_Date = InputParam_BookingDate and
((DB_StartTime <= InputParam_ endTime and DB_ EndTime >= InputParam_ startTime) or (DB_ StartTime < InputParam_ endTime and DB_ EndTime > InputParam_ startTime))

after that -check if the above aggregate  Isempty?
if Yes - allow to save 
if No - Do not allow for booking

This should work in your scenario

Cheers,
Shriyash Dixit

UserImage.jpg
Syakirah

Thank you so much, it worked. Thank you Shriyash

UserImage.jpg
Shriyash Dixit
2024-01-04 09-21-21
Venkatesaiya

Hi @Syakirah ,
In Booking_Detail Aggregate filter by Room no , Booking date get from the inputs and also filter by
start time is greater than End time . After check the condition if Aggregate is empty you allow to create the record.
Thanks

2024-01-04 09-21-21
Venkatesaiya

Can you please share your OML to solve this.

UserImage.jpg
Syakirah

Hi Venkatesaiya, mine has already worked, thank you for the idea.

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.