How to filter overlap between start-end date of new & existing objects?

1
Update 2: Fabian's answer is much better, obviously.. :) - - - - - - - - - - - - - - - - - - -  Update 1: I fixed it The first rule of them all says "filter an existing event where it's start date is smaller than $NewObject/StartDate and the existing end date is smaller than $NewObject/EndDate. That rule co-ops with the visual below nicely, but also applies when the new object is months later, as the starting date is still later and end date is as well. The fix is pretty easy. There is an additional check on the first rule that checks the start date compared to the end date. Obviously, as the single to last rule is exactly the opposite, so the opposite has to be applied to that rule as well, making the whole xpath to be: - - - - - - - - - - - - - - - - - - -    Let's create some easy context. I have a list of scheduled events and when I when I create a new event, it cannot overlap with a different event. Where A is startDate and B is endDate, 1 is existing object and 2 is new object, red is overlap and green is safe. To filter out, I did a Retrieve function on all events (In my case called 'AbsenceMoment') and by xpath checked if there is one that overlaps. Equal to the order of the image, from top to bottom, this is my xpath constraint: The $Absence objects are the new ones, thus being 2A & 2B. But somehow, even when I have an event that would be scheduled, both start and end date, months later, it will still retrieve a scheduled event and by doing so breaking the microflow to create a new event. I'm pretty sure somewhere my syntaxes are wrong, but I simply can't see it. Who can tell what is (/could be/) wrong?   P.S. I have multiple types of 'AbsenceMoment', hence the category, and multiple people can be assigned to such a moment. I'm iterating over each of the persons of the new event and check if any of them have an associated Moment that overlaps.
asked
1 answers
4

Try this one

$AbsenceMoment/EndDate > StartDate and $AbsenceMoment/StartDate < EndDate

 

answered