How to create a decision to prevent double booking?

0
I have a reservation application with time slots, Date(meaning the starting date time) and EndTime(end date time). I want my microflow to check all reservations, even future ones and see if the PickedDate and PickedEndTime are available. I have used a retrieve list of 'Reservation' from database and after that a decision but I'm having trouble with writing the decision. I have tried this:   $Reservation/PickedDate < $Reservation/EndTime and $Reservation/PickedEndTime > $Reservation/Date   but I get errors in my console "cannot create Mendix object. Check entity access for Administrator.Account".   I've found similar questions in this community forum but none really answered my issue. Thank you in advance :)
asked
4 answers
1

Hi Gal Verlic,

                  Check the security and access for the account entity

answered
0

Hi Gal,

 

Did you check the security level to the Entities and Microflow on your module/app for your user and module roles?

 

Regards,

Daniel

answered
0

Hi thank you both, that fixed my entity access error but now I'm trying to fix my logic for checking if the chosen time is available, right now I have two retrieves then a decision($Reservation/PickedDate < $Reservation/EndTime and $Reservation/PickedEndTime > $Reservation/Date) which throws an error and I also think it's incorrect. I want to check also if the availability is more than 0 for the chosen charger during that time because I have a scheduled task which increases the availability back to 1 when a reservation is finished

answered
0

Hi Gal,

 

To check the availability of an asset, you first check if there is a reservation within the selected date range. You can use a microflow indeed:

 

Retrieve first Reservation from database.

Xpath constraint:

[

Reservation_Asset = $PickedAsset

StartDate < $PickedEnd

and EndDate > $PickedStart

]

 

You can use a Non persistent entity to populate the search criteria. 

 

This should give you the answer if the asset has been reserved on the specified period => Use a Decision: if $Reservation = empty then true else false, whereby true means available and false means unavailable.

 

I don't suggest using a scheduled event each 30 secs as this is quite expensive.

 

Hope this helps.

 

Jeroen

answered