I am creating a workflow where I am attempting to check the start and end dates of a meeting room entry (via for each loop), compare the dates and if the current item start and end dates overlap, end the workflow. If no overlap after looping through confirm booking, do other actions etc.
So, I created a query list item that has a filter to filter all items that match the current item's meeting room (no point checking other items that are bookings for a different meeting room!) and also doesn't return the current item ID.
I then record their ID's in a collection variable called booking Items.
Next step, I created a for each loop that loops through the ID's (booking items collection variable) and outputs result to current Index variable (number). Inside the loop I have a query list action that returns items based on the meeting room field matching the current item meeting room value and where the ID matches the current Index variable, first ID inside booking items collection. I then output the returned item's start and end dates to two start and end date variables. I then have a condition action that then checks whether the start and end dates of the current item (the item the workflow is running against) are greater lesser etc than the variables start and end dates returned from the query list action inside the loop and if they overlap, end workflow and report double booking. If not, loop through checking next ID, /item. If no match- loop will end (as no more ID's to run through in booking item collection variable), then it does other booking actions outside of loop - send booking confirmation etc.
I have placed log to history values of the returned start and end date variables and value of current Index variable+ the current item's start and end dates and all appear to be in order.
Somehow the condition action in the loop, if start and end dates etc appears not to be working as an entry that clearly does not overlap the returned item in the for each loop stops the loop and reports an overlap / double booking.
I am so close to getting this to work I'd appreciate any help/advice.
My SharePoint list the workflow is attached to is just a calendar with start and end date fields and a choice column called meeting room with either London, Paris, Milan as choices.
Also, I attempted to do it in a normal loop where it loops through the amount of items instead. I found the same condition action logic works inside this loop (check the disabled loop/actions in the attached workflow) however the query action in the loop only returns the first item...how do I get it to return the next? if I use this kind of loop/go this route instead. I have attached the workflow.