Creating a list of date objects for each date between a StartDate and EndDate

0
Hi everyone, Thanks in advance for your help. I am trying to create a microflow that takes in 2 variables, a start date and an end date from the microflow parameter and then creates a list of objects for each date.  I am unsure of how to do this dynamically.  Does anyone have any ideas? Thanks again   Jack
asked
5 answers
0

Hi Jack,

The flow would something similar to the screenshot below. 

  1. Create a variable which is equal to the start date. You do this so you change the variable since it not possible to change an input parameter variable.
  2. Create the object with the date attribute.
  3. Check if your Date variable is past the enddate, if not continue in the loop.
  4. Change the date variable. If you want to add 1 day, you can use 
    addDays($Date,1)

     

I did not include the list in my screenshot, but you can create a list, or insert a list as input in the microflow, and add the objects you created to the list.

answered
0

More or less what was mentioned above (without recursion, it’s easier to read this way I guess):

  • Start a list
  • Create a pointer to see where we’re at (initial value = $From)
  • As long as the pointer is before $To
    • Create a new item
    • Add item to the list
    • Move the pointer by one day
    • Go back to before the decision point
  • Return the list

 

The example is crude (no validation, no sanitation of any time components to your from/to, etc) but this is the general idea.

answered
0

You can use a recursive microflow call where one input will be start date ,other end date, and a list variable to store date objects. In  microflow add create object , to store new date as startdate + adddays(1) and add to list and if current date equals end date then come to exit path or call same mf again recursively this will have new start date as input. (in Mendix 9  latest they have added while loop support which can also be used but its still in beta mode)

answered
0

I am not quite sure what you mean. Would it be possible to provide some more clarity on the recursive microflow?

answered
0

Thanks guys. All answers truly appreciated.

answered