I have a workflow that I want to loop through a list every day, store start dates, then later in the flow fire off alerts if today's date is one month, three months, or six months on from that initial start date.
I've set up a flow which adds the required dates to a 'Today's Date' variable, then runs and alert if the start dates equals the variable. That works fine, it's the scheduled For Each and Collection Operation I'm struggling with.
Here's how I've configured the 'For Each':
and here's the Collection Operation:
I'm getting 'Error operating on collection variable. Index property is greater than the number of items in the collection.' when the flow hits the Collection Operation. What's the best way to proceed? All help appreciated!
Solved! Go to Solution.
Could you explain why you are using the Collection operation to do the same thing that is accomplished in the For each? Both are setting Two_weeks_dates to the current item in the collection.
Also, is the Collection operation contained within the For each loop?
Thanks @ethurber thought I needed Collection Operation to store the information from the list? So I could just do a For Each and store in a Collection variable then use that to do the comparison in the Run IF action?
No. The for-each loops through the collection and stores each entry in the variable specified (not a collection variable). From what i can tell from your screenshot, you have the for-each configured properly. From that point, you can process that variable any way you want. Just be sure that all of the processing is in the for-each loop. When the processing is complete for that item, it will return to the top of the for-each and pull the next item from the collection and store it in the variable. It will repeat until all items in the collection are processed.
I hope this wasn't more information than you needed.
Thanks @ethurber that's really helpful.
So I want to store the user name and start date then have actions fire if the start date = the start date + three months. I have a query list action which is returning all the users names and start dates. What's the best way to store these variables so that I can do the comparison and trigger the actions?
This is how the For Each is configured:
and here's the flow as it stands:
Thanks for all your help!
This is what came up with based on my understanding of your requirements. It's a site workflow that is scheduled to run daily. I'm assuming that you wanted to send an email to the employee (i can't read the label on you send email action)
The query list action
For each action
Run if action
Hope this helps.
@ethurber how would I configure the Calculate cut-off-date action? I'd need it to be the Start Date plus 30 days and then store it in the datCutOffDate variable in your example?
The cutoff date is the current date - 90 days. This is used to filter the query because you are not interested in any dates older than 90 days.
Thank you so much for your help @ethurber . I'm a still a little confused by the cutoff date. For example I need the alerts to fire if the employee is one month on from their start date. So if their start date was the 16th I'd need it to fire send an alert on the 16th of December. So would I not get their start date then add a month in the Calculate Date and then would I need to filter the results later?