cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
PeggyLang
Helper IV
Helper IV

Help with Conditions

I have a flow that will post a message in a Teams Channel if a file has been modified.  I would like to put a condition that if a file has been modified by anyone OTHER than x, y, z.  I'm not sure how to add this condition.
Background - there are 3 'owners' of a document library that a team of 50 people have access to.  If someone OTHER than the 3 owners modifies a document we would like to know as the modification was probably/most likely in error, i.e., someone opening a file from the Sharepoint site and inadvertently editing the file online, or not downloading to their desktop prior to using the file for their own purposes.

 

1 ACCEPTED SOLUTION

Accepted Solutions
Zooney1
Helper II
Helper II

Although a Switch condition will work, to prevent the flow from running at all unless the condition is met, instead set a Trigger Condition using the steps below. 

Start with a Trigger, such as "When a files is created or modified"

  1. Click on the ellipsis
  2. Select Settings
  3. 4. & 5. - At the bottom of Settings, under Trigger Condition, click +Add 3 times
    Note: conditions must result in True for the flow to start/run, so you'll want to set it to where "Modified By" (or Editor) is not equal to the email address for X, Y or Z, so you your expression will combine both not() and equals().

Set three conditions using an expression similar to

 

@not(equals(triggerOutputs()?['body/Editor/Email'],'x@tenant.com'))​

 

Settings_AddTriggerCondition.png

For more details, read Power Automate Trigger Conditions made EASY

 

View solution in original post

8 REPLIES 8
AndoLalayan
Helper I
Helper I

@PeggyLang I believe the switch condition would do what you need.  Maybe something like this.

 

F4.jpg

Zooney1
Helper II
Helper II

Although a Switch condition will work, to prevent the flow from running at all unless the condition is met, instead set a Trigger Condition using the steps below. 

Start with a Trigger, such as "When a files is created or modified"

  1. Click on the ellipsis
  2. Select Settings
  3. 4. & 5. - At the bottom of Settings, under Trigger Condition, click +Add 3 times
    Note: conditions must result in True for the flow to start/run, so you'll want to set it to where "Modified By" (or Editor) is not equal to the email address for X, Y or Z, so you your expression will combine both not() and equals().

Set three conditions using an expression similar to

 

@not(equals(triggerOutputs()?['body/Editor/Email'],'x@tenant.com'))​

 

Settings_AddTriggerCondition.png

For more details, read Power Automate Trigger Conditions made EASY

 

View solution in original post

Hi @Zooney1 ,

 

This sounds like JUST what I need.  I am new to MS Flows - have written a few - and DEFINITELY NEW to the concept you have outlined.

I tried it however, and it does not seem to work as hoped.  I used my email in the @not(equals . . .  equation, created a file and the flow ran - although it should not have.  I'm guessing the syntax is off somehow??

 

@not(equals(triggerOutputs()?['body/Editor/Email'],'peggy.lang@xxxxxxxxx.com'))

 

I REALLY appreciate your help.

Hi Peggy - Can you post a couple of screenshots? Is your trigger on a SPO document library? Thanks

@Zooney1 , yes SP document library.

PeggyLang_0-1598384497113.png

PeggyLang_1-1598384529195.png

 

 

I double checked what I setup, edited the document and the run was skipped. I changed it to another email address, and it ran, I removed the not() wrapper and made an edit and it also worked. 

Troubleshooting ideas -  

  • The expression looks correct. If you copy/pasted, try removing the ' and retyping the ' , sometimes they get lost in translation, so to speak.
  • Another thing to try is remove the not() and then make an edit to the document, and then replace the not() and try it again. Or put another email address in there.
  • Double-check that you're logged into SPO with that same account, sometimes when I test I use alt accounts and that can trip me up.
  • If your flow was already setup you've added this trigger to it, save it wait a few minutes before making the edit to the document. 

Let me know where that gets you. 

Another thing to try to be certain the condition syntax is correct - 

  1. Copy the condition from the Trigger, and then delete that Add text input row
  2. Add the action: Variable > "Initialize variable" to create a variable
  3. Add a the action: Control > "Condition", set the condition on the left by adding dynamic content switch to "Expression" and paste it from the Trigger condition (without the @), click on Update. The expression should copy over, it you get an error, something is wrong with the syntax
  4. Set the other side of the condition to the expression "true"
  5. On the if Yes, set the variable to "The Editor is Not me", set the No side to "The Editor is me" 
  6. Save the Flow, make sure it finishes the save, then make some edits to the document.

PutTriggerConditionIntoConditionControlWithVariables.png

@Zooney1  I SO MUCH appreciate your help!!!!

I must admit though I really have no idea and have yet to be able to follow what you suggested after you said my trigger condition looked like it was good.  I tried to understand all of your thoughts/suggestions, but it is over my head at the moment.  
So . . . I went back to the trigger condition that I had input and kept looking at it.  Somehow something 'triggered' in my brain and decided to change my email address from peggy.lang@xxxxxxx.com to Peggy.Lang@xxxxxxxx.com

 

AND IT'S WORKING NOW!!!

I'm thrilled.  Thank you again.

Helpful resources

Announcements
MPA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

V3_PVA CAmpaign Carousel.png

Community Challenge - Giveaways!

Participate in the Power Virtual Agents Community Challenge

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

R2 (Green) 768 x 460px.png

Microsoft Dynamics 365 & Power Platform User Professionals

DynamicsCon is a FREE, 4 half-day virtual learning experience for 11,000+ Microsoft Business Application users and professionals.

Top Solution Authors
Users online (1,171)