Hi All,
I am trying to check whether a reservation runs successfully or encounters an error after it has completed. For example, I would like to use the GetAllReservations() method and loop through the reservations to determine whether each one succeeded or failed.

May I know if there is a way to achieve this?
Thanks!
Hi Jason,
You should use the Booking Life Cycle to determine that, if your reservation should have already ended and it failed that property should have either the value 'Failed' (if it failed to be setup correctly, e.g. elements are stopped at the booking start time) or 'FailedCompleted' (if the orchestration failed). Bellow you can find an example.
var allEndedReservations = SrmManagers.ResourceManager.GetReservationInstances(ReservationInstanceExposers.Status.Equal((int)ReservationStatus.Ended));
foreach (var endedReservation in allEndedReservations)
{
var bookingLifeCycle = endedReservation.GetBookingLifeCycle();
var isFailed = bookingLifeCycle == GeneralStatus.FailedCompleted /* Orchestration failed */ || bookingLifeCycle == GeneralStatus.Failed /* Booking failed to be setup correctly */;
}
Note: Please don't do GetReservations without any filter, I've put a filter only for Ended, but you should try to filter more. Getting a lot of reservations at once can take a significant amount of time.
Depending on your logic, try to make the filter even more strict.
E.g.: If this script run every hour, you only need to get reservation that are ended and the the end date is bigger than now minus one hour.
Thanks, Jorge. I tested, and it works. I also applied the filter to ensure it does not select all the reservations.