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. 

 

 

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.

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.

@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

Community will be READ ONLY July 16th, 5p PDT -July 22nd

Dear Community Members,   We'd like to let you know of an upcoming change to the community platform: starting July 16th, the platform will transition to a READ ONLY mode until July 22nd.   During this period, members will not be able to Kudo, Comment, or Reply to any posts.   On July 22nd, please be on the lookout for a message sent to the email address registered on your community profile. This email is crucial as it will contain your unique code and link to register for the new platform encompassing all of the communities.   What to Expect in the New Community: A more unified experience where all products, including Power Apps, Power Automate, Copilot Studio, and Power Pages, will be accessible from one community.Community Blogs that you can syndicate and link to for automatic updates. We appreciate your understanding and cooperation during this transition. Stay tuned for the exciting new features and a seamless community experience ahead!

Summer of Solutions | Week 4 Results | Winners will be posted on July 24th

We are excited to announce the Summer of Solutions Challenge!    This challenge is kicking off on Monday, June 17th and will run for (4) weeks.  The challenge is open to all Power Platform (Power Apps, Power Automate, Copilot Studio & Power Pages) community members. We invite you to participate in a quest to provide solutions to as many questions as you can. Answers can be provided in all the communities.    Entry Period: This Challenge will consist of four weekly Entry Periods as follows (each an “Entry Period”)   - 12:00 a.m. PT on June 17, 2024 – 11:59 p.m. PT on June 23, 2024 - 12:00 a.m. PT on June 24, 2024 – 11:59 p.m. PT on June 30, 2024 - 12:00 a.m. PT on July 1, 2024 – 11:59 p.m. PT on July 7, 2024 - 12:00 a.m. PT on July 8, 2024 – 11:59 p.m. PT on July 14, 2024   Entries will be eligible for the Entry Period in which they are received and will not carryover to subsequent weekly entry periods.  You must enter into each weekly Entry Period separately.   How to Enter: We invite you to participate in a quest to provide "Accepted Solutions" to as many questions as you can. Answers can be provided in all the communities. Users must provide a solution which can be an “Accepted Solution” in the Forums in all of the communities and there are no limits to the number of “Accepted Solutions” that a member can provide for entries in this challenge, but each entry must be substantially unique and different.    Winner Selection and Prizes: At the end of each week, we will list the top ten (10) Community users which will consist of: 5 Community Members & 5 Super Users and they will advance to the final drawing. We will post each week in the News & Announcements the top 10 Solution providers.  At the end of the challenge, we will add all of the top 10 weekly names and enter them into a random drawing.  Then we will randomly select ten (10) winners (5 Community Members & 5 Super Users) from among all eligible entrants received across all weekly Entry Periods to receive the prize listed below. If a winner declines, we will draw again at random for the next winner.  A user will only be able to win once overall. If they are drawn multiple times, another user will be drawn at random.  Individuals will be contacted before the announcement with the opportunity to claim or deny the prize.  Once all of the winners have been notified, we will post in the News & Announcements of each community with the list of winners.   Each winner will receive one (1) Pass to the Power Platform Conference in Las Vegas, Sep. 18-20, 2024 ($1800 value). NOTE: Prize is for conference attendance only and any other costs such as airfare, lodging, transportation, and food are the sole responsibility of the winner. Tickets are not transferable to any other party or to next year’s event.   ** PLEASE SEE THE ATTACHED RULES for this CHALLENGE**   Week 1 Results: Congratulations to the Week 1 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge.   Community MembersNumber SolutionsSuper UsersNumber Solutions Deenuji 9 @NathanAlvares24  17 @Anil_g  7 @ManishSolanki  13 @eetuRobo  5 @David_MA  10 @VishnuReddy1997  5 @SpongYe  9JhonatanOB19932 (tie) @Nived_Nambiar  8 @maltie  2 (tie)   @PA-Noob  2 (tie)   @LukeMcG  2 (tie)   @tgut03  2 (tie)       Week 2 Results: Congratulations to the Week 2 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge. Week 2: Community MembersSolutionsSuper UsersSolutionsPower Automate  @Deenuji  12@ManishSolanki 19 @Anil_g  10 @NathanAlvares24  17 @VishnuReddy1997  6 @Expiscornovus  10 @Tjan  5 @Nived_Nambiar  10 @eetuRobo  3 @SudeepGhatakNZ 8     Week 3 Results: Congratulations to the Week 3 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge. Week 3:Community MembersSolutionsSuper UsersSolutionsPower Automate Deenuji32ManishSolanki55VishnuReddy199724NathanAlvares2444Anil_g22SudeepGhatakNZ40eetuRobo18Nived_Nambiar28Tjan8David_MA22   Week 4 Results: Congratulations to the Week 4 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge. Week 4:Community MembersSolutionsSuper UsersSolutionsPower Automate Deenuji11FLMike31Sayan11ManishSolanki16VishnuReddy199710creativeopinion14Akshansh-Sharma3SudeepGhatakNZ7claudiovc2CFernandes5 misc2Nived_Nambiar5 Usernametwice232rzaneti5 eetuRobo2   Anil_g2   SharonS2  

Check Out | 2024 Release Wave 2 Plans for Microsoft Dynamics 365 and Microsoft Power Platform

On July 16, 2024, we published the 2024 release wave 2 plans for Microsoft Dynamics 365 and Microsoft Power Platform. These plans are a compilation of the new capabilities planned to be released between October 2024 to March 2025. This release introduces a wealth of new features designed to enhance customer understanding and improve overall user experience, showcasing our dedication to driving digital transformation for our customers and partners.    The upcoming wave is centered around utilizing advanced AI and Microsoft Copilot technologies to enhance user productivity and streamline operations across diverse business applications. These enhancements include intelligent automation, AI-powered insights, and immersive user experiences that are designed to break down barriers between data, insights, and individuals. Watch a summary of the release highlights.    Discover the latest features that empower organizations to operate more efficiently and adaptively. From AI-driven sales insights and customer service enhancements to predictive analytics in supply chain management and autonomous financial processes, the new capabilities enable businesses to proactively address challenges and capitalize on opportunities.    

Updates to Transitions in the Power Platform Communities

We're embarking on a journey to enhance your experience by transitioning to a new community platform. Our team has been diligently working to create a fresh community site, leveraging the very Dynamics 365 and Power Platform tools our community advocates for.  We started this journey with transitioning Copilot Studio forums and blogs in June. The move marks the beginning of a new chapter, and we're eager for you to be a part of it. The rest of the Power Platform product sites will be moving over this summer.   Stay tuned for more updates as we get closer to the launch. We can't wait to welcome you to our new community space, designed with you in mind. Let's connect, learn, and grow together.   Here's to new beginnings and endless possibilities!   If you have any questions, observations or concerns throughout this process please go to https://aka.ms/PPCommSupport.   To stay up to date on the latest details of this migration and other important Community updates subscribe to our News and Announcements forums: Copilot Studio, Power Apps, Power Automate, Power Pages

Users online (928)