power-automate

Advanced conditions in power automate


I have a flow that is responsible for creating/updating a sharepoint list with files from an email.

Essentially, the flow runs when an email arrives, I check the day and time the email arrives, and I add the file to a sharepoint list based on the day and time.

I need the sharepoint list to have only certain files in it at a certain time. For instance:

Any email that arrives between Friday 6pm - Monday 9am need to be put in the same list
Any email that arrives between Monday 6pm - Tuesday 9am need to be put in the same list
Any email that arrives between Tuesday 6pm - Wednesday 9am need to be put in the same list
Any email that arrives between Wednesday 6pm - Thursday 9am need to be put in the same list
Any email that arrives between Thursday 6pm - Friday 9am need to be put in the same list

However, I am having an issue building out the condition. Here are the expressions I use to get the day and time:

int(formatDateTime(triggerOutputs()?['body/receivedDateTime'], 'HH'))

dayOfWeek(triggerOutputs()?['body/receivedDateTime'])

How would I go about crafting my condition?


Solution

  • Your five conditions can be boiled down to two.

    The time stamp is before 9 am or after 6 pm, or the weekday is Saturday or Sunday

    or(
       or(
          less(hour(triggerBody()?['myDate']),9),
          greater(hour(triggerBody()?['myDate']),18)
       ),
       or(
          equal(dayOfWeek(triggerBody()?['myDate']),6),
          equal(dayOfWeek(triggerBody()?['myDate']),7)
       )
    )