0

I have a flow that triggers on When an item or a file is modified in a document library.

To stop it re-triggering when the item is updated, I'm checking that a DateTime field called FlowModified isn't within 2 minutes of the Modified time using this trigger condition:

@not(lessOrEquals(ticks(triggerBody()?['Modified']),ticks(addMinutes(triggerBody()?['FlowModified'],2))))

FlowModified has a default value, so for newly added files (though not for folders…), this is working fine.

The problem is that existing files in the library have nothing in FlowModified. And in this case it seems like FlowModified isn't returned at all in triggerBody() and I can't test its value.

Is there a way I can trigger my flow when FlowModified is empty as well as applying the condition above when FlowModified does contain a value?

1 Answer 1

1

Use OR in the trigger condition to connect such pieces:

@or(condition1, condition2, condition3,...)

Try as following to add another condition: equals(triggerOutputs()?['body/FlowModified'], null)

@or(not(lessOrEquals(ticks(triggerBody()?['Modified']),ticks(addMinutes(triggerBody()?['FlowModified'],2)))),equals(triggerOutputs()?['body/FlowModified'], null))

More information for your reference:

https://tomriha.com/a-simple-way-to-create-a-trigger-condition-in-power-automate/

4
  • Thank you, but this does not work. When I modify a file with nothing in the FlowModified field, the flow generates an error at the trigger (first) step: One or more fields provided is of type 'Null', a different type is expected. Commented Dec 7, 2021 at 23:06
  • (The question isn't about the or condition. I'm having trouble testing for the null/empty value in FlowModified.) Commented Dec 7, 2021 at 23:14
  • Oooo! I need to put the null test first in the or expression. Then once that is true, it doesn't go on to evaluate further things. I settled on @or(empty(triggerBody()?['FlowModified']),not(lessOrEquals(ticks(triggerBody()?['Modified']),ticks(addMinutes(triggerBody()?['FlowModified'],2))))) Commented Dec 7, 2021 at 23:46
  • The reason your one was failing is that addMinutes didn't like the null value. I don't really understand why this wasn't a problem in my question code… Oh well. It's working now. Commented Dec 7, 2021 at 23:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.