cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
mtagliaferri
Helper III
Helper III

Trigger Condition based on Choice Columns

I have a flow starting When an Item is created, under the settings I want his flow to trigger under certain condition, this condition is based on a column based on a Choice type set to Checkboxes and there is only on option ‘Do Not Send’

 

I have tried various trigger formulas but non are working, my question is can I set the trigger point using a Choice column? If so which is the correct formula as I seem to be getting nowhere.

 

The formulas I have tried are:

@not(contains(triggerOutputs()?['body/Notification'], 'Do Not Send'))

 

@not(equals(triggerOutputs()?['body/Notification'], 'Do Not Send'))

 

@contains(triggerOutputs()?['body/Notification'], null)

 

@equals(triggerOutputs()?['body/Notification'], '')

 

1.JPG2.JPG

 

1 ACCEPTED SOLUTION

Accepted Solutions

I'm sorry for that, I messed that up and it's two blocking conditions, I guess I had a hard day today... It'll trigger if the value is not empty, but at the same time it can't be equal to 'Do Not Send' which is your only choice. 😫

You want to trigger the flow only if the value is not selected, so you can use just the trigger condition that will check if the choice is empty, which is the reverse of the 1st condition, without the 'not(...)':

@empty(triggerOutputs()?['body/Notification'])

 



[ If I have answered your question, please Accept the post as a solution. ]
[ If you like my response, please give it a Thumbs Up. ]

[ I also blog about Power Automate solutions even for non-IT people. ]

View solution in original post

12 REPLIES 12
cdn4lf
Resolver I
Resolver I

You need to add /Value at the end of your output.

@not(equals(triggerOutputs()?['Notification/Value'], 'Do Not Send'))

 

tom_riha
Super User II
Super User II

Hello @mtagliaferri ,

the problem with Checkbox choice column is that it enables multiple values. And because it enables multiple values, it'll be structured as an array in Power Automate, even if it contains just a single choice.

[
  {
    "@odata.type": "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",
    "Id": 1,
    "Value": "Do Not Send"
  }
]

That means you must get into the array, take the the first (and only) item from the array (on index 0) and then access the actual Value from the first item.

@not(equals(triggerOutputs()?['body/Notification'][0]['Value'],'Do Not Send'))

 



[ If I have answered your question, please Accept the post as a solution. ]
[ If you like my response, please give it a Thumbs Up. ]

[ I also blog about Power Automate solutions even for non-IT people. ]

@tom_riha 

Thanks for the info, I have changed the code as suggested 

@not(equals(triggerOutputs()?['body/Notification'][0]['Value'],'Do Not Send')) 

 

but I am getting the following error now

Unable to process template language expressions for trigger 'When_an_item_is_created' at line '1' and column '8447': 'The template language expression 'not(equals(triggerOutputs()?['body/Notification'][0]['Value'],'Do Not Send')) ' cannot be evaluated because array index '0' cannot be selected from empty array. Please see https://aka.ms/logicexpressions for usage details.'.

 

cdn4lf
Resolver I
Resolver I

@mtagliaferri 

 

Please try my previously suggested code.  I am using this code today and it does work.

 

@not(equals(triggerOutputs()?['Notification/Value'], 'Do Not Send'))

 

@cdn4lf 

Hi, I have copied the formula but does not seem to trigger, I use the array component to build the formula as there is not an editor in the Settings of the Create item but when I select the notification Value it changes to Apply Each1.JPG2.JPG

@mtagliaferri 

 

Use the code as a trigger condition, not as a filter.  It should replace what you have in your red box in the initial post.

@cdn4lf I just use the array filter to create the code which I then copy and paste in the trigger settings and then delete the array step 

@mtagliaferri , I forgot the possibility of an empty value when the choice is not selected. It'll need two trigger conditions, 1st check if the choice column has any value (is not empty):

@not(empty(triggerOutputs()?['body/Notification']))

And then check the value itself:

@not(equals(triggerOutputs()?['body/Notification'][0]['Value'],'Do Not Send')) 

I'm not sure about the evaluation order of the trigger condition so I'd place the one to check empty value first and then the actual value, e.g. image.png

 



[ If I have answered your question, please Accept the post as a solution. ]
[ If you like my response, please give it a Thumbs Up. ]

[ I also blog about Power Automate solutions even for non-IT people. ]

@tom_riha 

By using this order:

3.JPG

 

I get this error:

Unable to process template language expressions for trigger 'When_an_item_is_created' at line '1' and column '8516': 'The template language expression 'not(equals(triggerOutputs()?['body/Notification'][0]['Value'],'Do Not Send')) ' cannot be evaluated because array index '0' cannot be selected from empty array. Please see https://aka.ms/logicexpressions for usage details.'.

 

By using the other way round

4.JPG

There is no trigger at all and no error

 

 

I'm sorry for that, I messed that up and it's two blocking conditions, I guess I had a hard day today... It'll trigger if the value is not empty, but at the same time it can't be equal to 'Do Not Send' which is your only choice. 😫

You want to trigger the flow only if the value is not selected, so you can use just the trigger condition that will check if the choice is empty, which is the reverse of the 1st condition, without the 'not(...)':

@empty(triggerOutputs()?['body/Notification'])

 



[ If I have answered your question, please Accept the post as a solution. ]
[ If you like my response, please give it a Thumbs Up. ]

[ I also blog about Power Automate solutions even for non-IT people. ]

View solution in original post

@tom_riha Don't apologise!!

 

You just nailed it and is working 😀

yols
Regular Visitor

I have a similar issue, but even though I'm using your solution @tom_riha, when the condition true, the flow runs every 30 seconds and it doesnt stop. Actually I noticed that even though I'm not editing the item that meets the condition, the flow runs in an eternal loop.  I don't get it, thoughts?

Helpful resources

Announcements
MBAS Attendee Badge

Claim Your Badge & Digital Swag!

Check out how to claim yours today!

MPA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

secondImage

Are Your Ready?

Test your skills now with the Cloud Skill Challenge.

Top Solution Authors
Users online (89,080)