cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous
Not applicable

Multiple criteria in one trigger condition (AND operator, etc)

Hi there. I don't expect this to be super complicated but I'm not totally clued up on Flow expressions just yet and have a question. I have a Sharepoint Created / Modified trigger and I currently have a handful of Condition > Terminate functions to kill off the flow under certain conditions, and would like to make use of trigger conditions instead in order to save flow runs. I'm just trying to wrap my head around the terminology though. Could someone clarify what the actual expression would be if I wanted the flow to ONLY run when:

STATUS column = Pending Approval
AND
APPROVER column contains information

It's pretty simply doing this with the terminate condition, and I know / think the beginnings of the expression will be something along the lines of the below, but expanding this to accommodate the two pieces of criteria with AND operator I'm unsure about. Can anyone advise?

@equals(triggerBody()?['STATUS']?['value'],'Pending Approval')

13 REPLIES 13
Pstork1
Most Valuable Professional
Most Valuable Professional

The following code works for me.  You may have to play with the field names if yours are different. But this is the syntax.

@And(equals(triggerBody()?['ApprovalStatus'], 'Pending'),equals(empty(triggerBody()?['Approvers']), false))


-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

Or you can just click "Add" to add more expressions, this would be taken as And as well.

Pstork1
Most Valuable Professional
Most Valuable Professional

He's building a Trigger condition.  There is no "Add" in that dialog yet.  You have to build it as a string.



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

Hello, I see there is now a +Add function built into the Trigger Conditions so you don't have to build it into the string.  Unfortunately I need to put both AND and OR into one string.  

 

I'm already using Array: @triggerOutputs()?[‘body/value’] and Trigger Condition @contains(triggerBody()?.

 

I want to expand the trigger condition to this:

@contains(triggerBody()?[‘{FilenameWithExtension}’],’.xlsm’)
AND
@equals(triggerOutputs()?[‘body/{ModerationStatus}’], ‘Approved’) AND @equals(triggerOutputs()?[‘body/{IsCheckedOut}’], false)
OR
@equals(triggerOutputs()?[‘body/{ModerationStatus}’], ‘Denied’) AND @equals(triggerOutputs()?[‘body/{IsCheckedOut}’], false

 

I'd be most appreciate if you're able to help:

1) I’m not clear on how to nest the 2 AND conditions in to the OR condition. 

2) I'm not clear on whether I need to make any changes to the @triggerOutputs()?[‘body/value’] that is in the Array field because I added the original trigger condition so long ago I don't recall why I added that Array. 

 

 

Pstork1
Most Valuable Professional
Most Valuable Professional

You just nest the conditions as needed. 

@And(
    contains(triggerBody()?['{FilenameWithExtension}'],'.xlsm'),
    or(
        and(
            equals(triggerOutputs()?['body/{ModerationStatus}'], 'Approved'),
            equals(triggerOutputs()?['body/{IsCheckedOut}'], false)
            ), 
        and(
            equals(triggerOutputs()?['body/{ModerationStatus}'], 'Denied'),
            equals(triggerOutputs()?['body/{IsCheckedOut}'], false)
            )
      )
  )


-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

Thank you so much!  It never occurred to me to try to separate it out on different lines to make sense of it.  Although that's what I do when I have to fool with VBA in Excel.  BTW not a big deal but do you know what kind of code this is that we use in Power Automate?  Just this one time I happened to ask one of our developers for help with this, and he could not help, but he said I could get back to him if I knew what language it was.  I just Initialize Variable and hit Advanced and copy/paste the expression it gives me.  But I don't know what language it is.

Pstork1
Most Valuable Professional
Most Valuable Professional

Its not really a specific language since this is a low code/no code system.  the closest would be Excel or Azure Logic app functions.



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.
eliotcole
Super User
Super User

@Anonymous , I'm sure you've got a good answer below, but if you want a really easy way to go about making a trigger condition, just use a filter to make it, tap the 'advanced' link, and copy the formula out of that!

 

I've copied a step by step for this in the below spoiler (supplied to a user who was similarly wary about expressions) which should guide you through just how easy it is:

Spoiler

Trigger Condition

You need this here to ensure that this flow doesn't run for every single change on the list.

 

Follow these steps to easily create a trigger condition:

1

Add an action

Select a point anywhere in the flow and choose 'Add an action', then 'Data Operation'.

1 - Add an action.jpg
2

Filter array

Select 'Filter array' from the choices.

2 - Filter.jpg
3

Select column

In the left side of the Filter array condition insert a Dynamic Value, and select your desired column.

 

In this example we're choosing 'Status', which is listed as 'Status Value' as it is a choice column on my list.

3 - Pick Column.jpg
4

Enter the condition text

Now in the middle you choose your condition logic, in this case, you wish to ensure that the column is equal to a value that you state, so you choose 'is equal to' here.

 

Then on the right side you want to place the value that you wish the trigger of the flow to fire upon. So here you either type, or copy directly from the list settings the value that you need to match.

4 - Enter text.jpg
5

Edit in advanced mode & Copy Text

Tap 'Edit in advanced mode' and copy or cut all the text from that box using CTRL+A to ensure it's all selected.

5 - Tap 'Edit in advanced mode' and cut all the text.jpg
6

Delete the Filter array

Tap the three dot menu on the Filter array, and select 'Delete'

6 - Delete the Filter array.jpg
7

Go to Trigger Settings

Tap the dot menu on the trigger and select 'Settings'

7 - Tap the dot menu on the trigger and select 'Settings'.jpg
8

Paste Trigger Condition

Look to the bottom of the Trigger Settings you will see the Trigger Condition section.

 

Add a new Trigger Condition and paste the details that you cut from the Filter inside it.

8 - Add a Trigger Condition and paste the details that you cut from the Filter.jpg

 

Congratulations, you have made your first trigger condition!

🏆

Sadly that does not help with combining multiple trigger conditions.  It just gets you the trigger conditions to start with and you have to figure out how to combine them yourself.  It makes me think though, if you can use a Condition action and neatly put in all your "and" and "or" conditions without code, I wish Microsoft would use that same Condition screen in the trigger condition.

It isn't supposed to help with combining, @AntoinetteB, the list of Trigger Conditions is inherently an and() wrapper.

 

You're right, though, about using that Condition action front end, it does need that.

 

When someone is just starting out learning this stuff then it's far more applicable to:

  1. Make one trigger condition using the Filter method, add it as a trigger condition.
  2. Make another trigger condition using the Filter method, and add that as another trigger condition, too.

See below spoiler for how that might look:

Spoiler

multipleTriggerConditions.jpg

Now this will trigger only if 'Status' = "In progress" and 'Priority' = "High" ... or in expression terms:
and(
    equals(
        triggerOutputs()?['body/Priority']?['Value'], 
        'High'
    ),
    equals(
        triggerOutputs()?['body/Status']?['Value'], 
        'In progress'
    )
)
So if I really wanted to, I could just have one Trigger Condition of:
@and(equals(triggerOutputs()?['body/Priority']?['Value'], 'High'), equals(triggerOutputs()?['body/Status']?['Value'], 'In progress'))

Saying something like this could make a person new to the system doubt that it will work effectively, which isn't fair on them, Antoinette. Because something like this does work, especially for helping people new to expressions to add a simple Trigger Conditions.

 

What it *doesn't* do is help with an or() Trigger Condition. If someone new to expressions, who is still uncomfortable with the expression builder, then they may still wish to use the filter method.

 

An or() trigger can still be made, though, but it is *technically* writing an expression. The easiest way to do this using the Filter method would be what I've plotted out in this spoiler, which one could also use for and():

Spoiler
  1. Open a notepad and type the following on the first line:
    and(

     

  2. Add another line and type the following on the new line:
    )

     

  3. Make a condition using the Filter method.

  4. Copy that condition on to a new line inbetween the 'and(' and ')' lines

  5. Repeat #3 and #4 for as many conditions needed.

  6. Once done, add a comma to the end of condition, except the last one.

  7. Go to the ')' line, and begin to consolidate the lines into one by backspacing from the start of each line.

  8. You have an or() condition!

 

I am someone new to expressions.  I don't code at all.  And I've been experiencing the very problem I'm talking about where it actually did not work effectively.  I'm speaking to my own reality.  LOL I was trying to say that there are so many articles where people tell you how to hit the Advanced link on the Array action to create the expression and then delete the array, but not much to help to combine all the nested and/or.  I actually created an official suggestion for this a few minutes ago with Microsoft because I doubt I'm the only no code person relying on the generosity of people like pstork and yourself for the code to put in. 

 

Thank you so much for the second spoiler.  This helps me learn how to code; kind of like training wheels.  I had already taken pstorks code he gave me and looked at it against my Condition action UI to see how it matches up and how to structure that on my own.  I will also use your spoiler to add my my arsenal of when I have to code in order to use Power Automate effectively.   (Except that my scenario request AND and OR, not one or the other but both.) Also, I think I might have thought you were responding to my question to pstork along with the original person, which was not just to convert to an expression, but you were really only talking to him.  My confusion, the replies here are sometimes hard for me to follow.  🙂  

👍👍👍👍👍👍👍

 

Oh, seriously, don't worry about it ... I operate on the assumption that I'm the least important person in a room, so it's relatively hard to irk me.

 

I still think you're absolutely right, though, that it needs a better interface.

 

I didn't know about all the articles online telling folks how to make the trigger conditions using the Filter action. But believe you me, I'll be repeating it again on this place. 😅

----

 

With regards to what you're saying, though, I feel your pain.

 

Just remember, though, each Trigger Condition is adding an extra condition to an invisible and() expression. 😉

 

----

 

Also, I am new to coding myself. On the surface of it, I believe that (in general) Power Automate flows should be made so that anyone could possibly look at the flow and understand what is happening.

 

That is why if it's a flow made by a member of staff that isn't perhaps in a technical role, for the benefit of other members of staff, then it should be a simple as possible. I mean we're trying to get AWAY from those darned spreadsheet formulas, here! 

 

If I can offer one little nugget, there, though ... if you ever find that you've spent a long time on either some complicated logic, or that you've used an expression anywhere in a flow ... try to annotate that. Either purely by pasting the complicated expression in the 'Add a note' section of an action, or by talking through what's happening in the same field.

 

In coding I'm sure the equivalent is to add comments to your code to annotate it.

Hi, thank you for the tips.  I'm the only one at the bank who creates flows and I'm not technical.  I never annotate anything.  I go back and open a previous flow and look at what I did before and then use that to refresh my memory on how to solve a new challenge in my latest flow.  I'll have to look into leaving myself some notes in the future. 🙂

Helpful resources

Announcements

Calling all User Group Leaders and Super Users! Mark Your Calendars for the next Community Ambassador Call on May 9th!

This month's Community Ambassador call is on May 9th at 9a & 3p PDT. Please keep an eye out in your private messages and Teams channels for your invitation. There are lots of exciting updates coming to the Community, and we have some exclusive opportunities to share with you! As always, we'll also review regular updates for User Groups, Super Users, and share general information about what's going on in the Community.     Be sure to register & we hope to see all of you there!

April 2024 Community Newsletter

We're pleased to share the April Community Newsletter, where we highlight the latest news, product releases, upcoming events, and the amazing work of our outstanding Community members.   If you're new to the Community, please make sure to follow the latest News & Announcements and check out the Community on LinkedIn as well! It's the best way to stay up-to-date with all the news from across Microsoft Power Platform and beyond.    COMMUNITY HIGHLIGHTS   Check out the most active community members of the last month! These hardworking members are posting regularly, answering questions, kudos, and providing top solutions in their communities. We are so thankful for each of you--keep up the great work! If you hope to see your name here next month, follow these awesome community members to see what they do!   Power AppsPower AutomateCopilot StudioPower PagesWarrenBelzDeenujialexander2523ragavanrajanLaurensMManishSolankiMattJimisonLucas001AmikcapuanodanilostephenrobertOliverRodriguestimlAndrewJManikandanSFubarmmbr1606VishnuReddy1997theMacResolutionsVishalJhaveriVictorIvanidzejsrandhawahagrua33ikExpiscornovusFGuerrero1PowerAddictgulshankhuranaANBExpiscornovusprathyooSpongYeNived_Nambiardeeksha15795apangelesGochixgrantjenkinsvasu24Mfon   LATEST NEWS   Business Applications Launch Event - On Demand In case you missed the Business Applications Launch Event, you can now catch up on all the announcements and watch the entire event on-demand inside Charles Lamanna's latest cloud blog.   This is your one stop shop for all the latest Copilot features across Power Platform and #Dynamics365, including first-hand looks at how companies such as Lenovo, Sonepar, Ford Motor Company, Omnicom and more are using these new capabilities in transformative ways. Click the image below to watch today!   Power Platform Community Conference 2024 is here! It's time to look forward to the next installment of the Power Platform Community Conference, which takes place this year on 18-20th September 2024 at the MGM Grand in Las Vegas!   Come and be inspired by Microsoft senior thought leaders and the engineers behind the #PowerPlatform, with Charles Lamanna, Sangya Singh, Ryan Cunningham, Kim Manis, Nirav Shah, Omar Aftab and Leon Welicki already confirmed to speak. You'll also be able to learn from industry experts and Microsoft MVPs who are dedicated to bridging the gap between humanity and technology. These include the likes of Lisa Crosbie, Victor Dantas, Kristine Kolodziejski, David Yack, Daniel Christian, Miguel Félix, and Mats Necker, with many more to be announced over the coming weeks.   Click here to watch our brand-new sizzle reel for #PPCC24 or click the image below to find out more about registration. See you in Vegas!       Power Up Program Announces New Video-Based Learning Hear from Principal Program Manager, Dimpi Gandhi, to discover the latest enhancements to the Microsoft #PowerUpProgram. These include a new accelerated video-based curriculum crafted with the expertise of Microsoft MVPs, Rory Neary and Charlie Phipps-Bennett. If you’d like to hear what’s coming next, click the image below to find out more!   UPCOMING EVENTS Microsoft Build - Seattle and Online - 21-23rd May 2024 Taking place on 21-23rd May 2024 both online and in Seattle, this is the perfect event to learn more about low code development, creating copilots, cloud platforms, and so much more to help you unleash the power of AI.   There's a serious wealth of talent speaking across the three days, including the likes of Satya Nadella, Amanda K. Silver, Scott Guthrie, Sarah Bird, Charles Lamanna, Miti J., Kevin Scott, Asha Sharma, Rajesh Jha, Arun Ulag, Clay Wesener, and many more.   And don't worry if you can't make it to Seattle, the event will be online and totally free to join. Click the image below to register for #MSBuild today!   European Collab Summit - Germany - 14-16th May 2024 The clock is counting down to the amazing European Collaboration Summit, which takes place in Germany May 14-16, 2024. #CollabSummit2024 is designed to provide cutting-edge insights and best practices into Power Platform, Microsoft 365, Teams, Viva, and so much more. There's a whole host of experts speakers across the three-day event, including the likes of Vesa Juvonen, Laurie Pottmeyer, Dan Holme, Mark Kashman, Dona Sarkar, Gavin Barron, Emily Mancini, Martina Grom, Ahmad Najjar, Liz Sundet, Nikki Chapple, Sara Fennah, Seb Matthews, Tobias Martin, Zoe Wilson, Fabian Williams, and many more.   Click the image below to find out more about #ECS2024 and register today!     Microsoft 365 & Power Platform Conference - Seattle - 3-7th June If you're looking to turbo boost your Power Platform skills this year, why not take a look at everything TechCon365 has to offer at the Seattle Convention Center on June 3-7, 2024.   This amazing 3-day conference (with 2 optional days of workshops) offers over 130 sessions across multiple tracks, alongside 25 workshops presented by Power Platform, Microsoft 365, Microsoft Teams, Viva, Azure, Copilot and AI experts. There's a great array of speakers, including the likes of Nirav Shah, Naomi Moneypenny, Jason Himmelstein, Heather Cook, Karuana Gatimu, Mark Kashman, Michelle Gilbert, Taiki Y., Kristi K., Nate Chamberlain, Julie Koesmarno, Daniel Glenn, Sarah Haase, Marc Windle, Amit Vasu, Joanne C Klein, Agnes Molnar, and many more.   Click the image below for more #Techcon365 intel and register today!     For more events, click the image below to visit the Microsoft Community Days website.      

Tuesday Tip | Update Your Community Profile Today!

It's time for another TUESDAY TIPS, your weekly connection with the most insightful tips and tricks that empower both newcomers and veterans in the Power Platform Community! Every Tuesday, we bring you a curated selection of the finest advice, distilled from the resources and tools in the Community. Whether you’re a seasoned member or just getting started, Tuesday Tips are the perfect compass guiding you across the dynamic landscape of the Power Platform Community.   We're excited to announce that updating your community profile has never been easier! Keeping your profile up to date is essential for staying connected and engaged with the community.   Check out the following Support Articles with these topics: Accessing Your Community ProfileRetrieving Your Profile URLUpdating Your Community Profile Time ZoneChanging Your Community Profile Picture (Avatar)Setting Your Date Display Preferences Click on your community link for more information: Power Apps, Power Automate, Power Pages, Copilot Studio   Thank you for being an active part of our community. Your contributions make a difference! Best Regards, The Community Management Team

Hear what's next for the Power Up Program

Hear from Principal Program Manager, Dimpi Gandhi, to discover the latest enhancements to the Microsoft #PowerUpProgram, including a new accelerated video-based curriculum crafted with the expertise of Microsoft MVPs, Rory Neary and Charlie Phipps-Bennett. If you’d like to hear what’s coming next, click the link below to sign up today! https://aka.ms/PowerUp  

Super User of the Month | Ahmed Salih

We're thrilled to announce that Ahmed Salih is our Super User of the Month for April 2024. Ahmed has been one of our most active Super Users this year--in fact, he kicked off the year in our Community with this great video reminder of why being a Super User has been so important to him!   Ahmed is the Senior Power Platform Architect at Saint Jude's Children's Research Hospital in Memphis. He's been a Super User for two seasons and is also a Microsoft MVP! He's celebrating his 3rd year being active in the Community--and he's received more than 500 kudos while authoring nearly 300 solutions. Ahmed's contributions to the Super User in Training program has been invaluable, with his most recent session with SUIT highlighting an incredible amount of best practices and tips that have helped him achieve his success.   Ahmed's infectious enthusiasm and boundless energy are a key reason why so many Community members appreciate how he brings his personality--and expertise--to every interaction. With all the solutions he provides, his willingness to help the Community learn more about Power Platform, and his sheer joy in life, we are pleased to celebrate Ahmed and all his contributions! You can find him in the Community and on LinkedIn. Congratulations, Ahmed--thank you for being a SUPER user!

Tuesday Tip: Getting Started with Private Messages & Macros

Welcome to TUESDAY TIPS, your weekly connection with the most insightful tips and tricks that empower both newcomers and veterans in the Power Platform Community! Every Tuesday, we bring you a curated selection of the finest advice, distilled from the resources and tools in the Community. Whether you’re a seasoned member or just getting started, Tuesday Tips are the perfect compass guiding you across the dynamic landscape of the Power Platform Community.   As our community family expands each week, we revisit our essential tools, tips, and tricks to ensure you’re well-versed in the community’s pulse. Keep an eye on the News & Announcements for your weekly Tuesday Tips—you never know what you may learn!   This Week's Tip: Private Messaging & Macros in Power Apps Community   Do you want to enhance your communication in the Community and streamline your interactions? One of the best ways to do this is to ensure you are using Private Messaging--and the ever-handy macros that are available to you as a Community member!   Our Knowledge Base article about private messaging and macros is the best place to find out more. Check it out today and discover some key tips and tricks when it comes to messages and macros:   Private Messaging: Learn how to enable private messages in your community profile and ensure you’re connected with other community membersMacros Explained: Discover the convenience of macros—prewritten text snippets that save time when posting in forums or sending private messagesCreating Macros: Follow simple steps to create your own macros for efficient communication within the Power Apps CommunityUsage Guide: Understand how to apply macros in posts and private messages, enhancing your interaction with the Community For detailed instructions and more information, visit the full page in your community today:Power Apps: Enabling Private Messaging & How to Use Macros (Power Apps)Power Automate: Enabling Private Messaging & How to Use Macros (Power Automate)  Copilot Studio: Enabling Private Messaging &How to Use Macros (Copilot Studio) Power Pages: Enabling Private Messaging & How to Use Macros (Power Pages)

Users online (5,541)