"Get Items' action sends multiple items in one email and sends duplicated emails if the conditions are met. But my req is ' Send different tasks(items) at different frequency to different audiences '.
I want each item to be sent separately not in bulk. Also I want to pause if there is no task this month or week. I think the pic below would make my requirement a bit clear.
Req 1, IF 'pause' is selected in SP choice field don't trigger , IF 'Make this a repeating event' is selected trigger the flow.
Req 2, IF the item is submitted as a 'Weekly ' task Send email every week with info pulled from SP but don't send all the items that meet that criteria in bulk (in one email). Instead one email per one item. eg, If there are 3 monthly items /tasks submitted in the SP list It has to be emailed separately.
I thought get item action would meet the need but seems i can't use get item after recurrence trigger b/c it requires ID. Any other way I could meet the 2 req above mentioned? Can I use condition for 'recurrence' trigger ? Or how can i use recurrence as an action instead of trigger? I have conditions and those have to be met to send emails every week/month
@AWorley, @PowerExplorer reached out asking for more help.
I’m not sure how much more you want to complicate / customize this later, but if your requirements are really only what you have stated thus far, I might just…
Set a user input on the list for the week number(s) of the month, set a user input for the hour (integers only), & set a user input for the day of the week, then a calculated column that returns the day number for each day of the week.
Set a recurrence to run every hour of every day.
Calculate the current datetime of the current timezone by adjusting utcnow() with additional timezone expressions or actions.
Use a Get items with the Filter query set to get everything that isn’t paused.
Then set a Filter array to get the items where the week number matches the current week number, week day number matches the current week day number, & hour integer matches the current hour number.
That way you could Parse JSON on that Filter outputs & run your notifications or whatever else with the set of records you want from there.
You would do a Delay Until action and just do the time actions to manipulate the dates.
Something Like this would work. You'll have to tinker with the Expression to get the specific dayofweek values to match up as true so
Do until: dayofweek(utcnow()) IS EQUAL TO 1 OR 4.
(Sunday = 0, Saturday = 6)
Nested in the Do Until will be the delay until 10 AM function.
Delay Until: Expression for 10 AM:
addHours(startOfDay(addDays(utcNow(),1)),10)
For your monthly and weekly you can do a condition statement for both in a single flow. From there you can build out your "pause" action which would be a do until "pause" is equal to True. Then in your trigger statement just add a condition for pause is equal to false with the action "When an item is created or modified."
This will terminate the flow if pause is true. Then restart the flow from scratch when pause is false.
EDIT: I put some more thought into this. You will want to put the Delay until AFTER the Do Until and have the Do until as a hollow action.
Then you will want to modify the expression: addHours(startOfDay(addDays(utcNow(),1)),10) to account for time zone differences in UTCNow() time zone. So UTC time is +4 Hours from EST time. So if I were to do this expression the Delay until will trigger 4 hours earlier than require so the expression would need to be changed to 14 from 10. addHours(startOfDay(addDays(utcNow(),1)),14)
@AWorley Thank you for the speedy response . I think your idea is a potential solution and I'm going to check it out. But quick question, Can I set the delay until specific date and time like recurrence trigger in power automate ? or give users some kinda UI where they put the date and time in SP so the power automate reads that and runs based on that info? Eg, Every Monday at 11 am.
Some of the monthly tasks email goes out every Wed, at 10am, Or the weekly every Mon 11am. So the point is the email has to go out on the same day and time of the week or Month or Bi weekly. And am planning to use 'when item is created/modified' cuz when pause is elected it should stop. Thanks a lot for the assistance. This community means a lot to me.
The reason you are getting them in batches is because you are reoccurring every week and pulling the items into a for each loop without really a restriction.
Just so I can communicate I understand your requirements:
1. Must run weekly
2. Must pause if no actionable tasks are taken (weekly or monthly).
3. If pause is selected in SP Choice field Don't trigger. If 'Make this a repeating event" is selected trigger the flow.
4. If the item is submitted as a weekly task, send email every week with info pulled from SP but don't send all items that meet the criteria in bulk.
For me I would do the trigger "When an Item is created". Then use a Trigger condition for the criteria of #3. below is an example of a trigger condition for SharePoint list options. Replace fields for your situation.
@equals(triggerBody()?['COLUMNNAME'],'VALUEOFOPTION')
Then I would do a Do Until action for a value that would tell the flow the item is completed.
Inside the Do Until you will do all logic for handling the email until the field you mark returns true:
Delay Action: 1 Week.
Get Item: Trigger ID Field.
Condition statement for if weekly task:
if Yes: Send email.
If No: Do nothing.
I would nest Condition statements to account for if the item's modified time field is unchanged to account for if the item was not touched.
This will handle each item individually while also achieving your weekly threshold, and if no items were created then no flow runs achieving the final requirement.
Attaching here the rest of the pics