Commit Does no apply on all entity in the same microflow

0
Hi there , I have reservation app each day has seats when user click on submit I want to subtract the open seats in entity day it is work fine but when two person submit on the same moment the reservation will commit correctly but the number that should subtracted from day apply for only on seat not two for example when there is 20 available  seats and two reservations in the same moment the available seats should be 18 but it is 19 I tried this case many times and still got wrong result, and I tried every possible things could cause that in my microflow but still the same ,can anyone help me please.
asked
1 answers
0

Hi Mohsin,

 

I would suggest a different flow to calculate that numberReservationSpotsRemaining attribute so that it will be more reliable and accurate.

 

Whenever a reservation is confirmed, you should create an object called Reservation which has a boolean attribute called isConfirmed and a dateTime attribute called ReservationDate.  Whenever a user confirms a reservation this object will be created and associated to them.

 

On this object, you can have an after commit event which retrieves all the confirmed Reservation objects for the given dateTime and counts them. The numberReservationSpotsRemaining can be set by subtracting the confirmed count from the total available reservations on the given date.  This way you can be sure that the remaining count is always accurate.

 

Note, for the example above I used date to filter the reservation objects but if the reservations are associated to a specific event object, then you could use that association, in addition to the confirmed boolean, to retrieve all the objects that should be counted as reservations.

 

You will also need to add a way to handle if the remainingReservationSpotsRemaining ever gets to 0.

 

There are more plenty more potential features to improve your user experience, depending on your use case, but I hope this gets you going in the right direction!

answered