Hi Everyone, I having a problem to make condition or flow for my booking meeting room reactive apps. I only making booking meeting room for ONE room only. I have already set the Date, Start Time and End Time as Unique Entity Attributes. Can someone gave me an idea or show me an example on how to make the condition for duplicate booking meeting room?
The Get...ForUpdate action is just like the other CRUD actions that can be found under the corresponding entity. The difference between Get[EntityName] and Get[EntityName]ForUpdate is, that the second one is setting an exclusive write lock to the record. This avoids issues due to concurrent users trying to manipulate the same record at the same time. The lock is automatically removed when the transaction is closed.
In the aggregate, the fourth filter is to exclude the record to be updated because otherwise it could conflict with its own timeslot. "BookingId" is the variable (normally the input parameter) which is holding the ID of the booking to be updated. If you are getting warning messages regarding the data type, try wrapping in the ...ToIdentifier converter function. So if for example your booking Id is of type text, use TextToIdentifier(BookingId). There are similar converter functions for the other base types (e.g. IntegerToIdentifier).
Hi , can you please share the OML please .
here is it.
Hi
Please check oap package for booking application.
Hope it helps you.
Thank you
Hi, I already search it at Forge platform and research the apps that related to booking application but I still can't find the most suitable logic or workflow that suit with my booking meeting room application. Do you have any links that you might know that have similar booking systems like mine?
Hi,
I guess what you want to achieve is to avoid time collisions of bookings. Making the attributes unique in the database will not help you out here. What you need here, is some validation logic, that for a given booking A checks if there is another booking B already in the database that:
Hope this helps, Sebastian
Hi, firstly i want to thank you for the explanation you has given. But i still can't these logic in Server Actions since i still a beginner, is there a way you can show me how to implement or wrote the logic?
Thank you.
Sure, based on a database model like this one:
To add new bookings you should implement a server action as follows:
For updating bookings this works the same way but you need to exclude the booking to be updated from the conflict query:
If you want to have a single CreateOrUpdate instead, you can use the aggregate used in the update action. As long as you are passing NullIdentifier() as BookingId for a new booking, this will also work in validation.
Hi sebastian, thank you so much for the method you have taught me. I tried to apply the logic by following the step you shown but I can get the same result as your for the ValidationExeption and for Update Booking, can i know where I can get the GetBookingForUpdate server action? This is what I have implemented, sorry just ignore the entity attributes of BookingDetail. and for the aggregates I can't do the condition for booking.Id can i know if you change the datatype of the Id or not?
Hi Siti Nur,
I have attached the OML that might help you to solve your problem.
Hi Milind,
if you are copying someone else's answer, you should not suggest a solution that violates the best practices of OutSystems documentation.