cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
petergriac
Helper II
Helper II

do nothing in if function

Hi all,

Does anyone know how to write 'do nothing' in if statement when the condition is not true?

example if ( condition, 'do an action', 'do nothing')

 

Thanks in advance

1 ACCEPTED SOLUTION

Accepted Solutions
v-yuazh-msft
Community Support
Community Support

Hi @petergriac,

 

If you want to do nothing when the condition is not true, you just need to leave the If no branch of the Condition blank, do not add any actions in it.

And you could add actions that you want to to do in the If yes branch of the Condition.

 

Best regards,

Alice

View solution in original post

13 REPLIES 13
NigelP
Kudo Kingpin
Kudo Kingpin

Hi 

 

Just put false in the false part of the If STatement

 

Regards

 

Nigel

v-yuazh-msft
Community Support
Community Support

Hi @petergriac,

 

If you want to do nothing when the condition is not true, you just need to leave the If no branch of the Condition blank, do not add any actions in it.

And you could add actions that you want to to do in the If yes branch of the Condition.

 

Best regards,

Alice

Thanks,

This works.

 

Regards,

Peter

In my case this does not work. It throws my an error 

 
"ActionFailed. An action failed. No dependent actions succeeded" 
 
Any ideas how to work around this error?
VictorIvanidze
Community Champion
Community Champion

Fix the dependent actions, I guess?

--------------------------------------------------------------------------------------
Contact me if you are interested in custom Power Automate development.

How can we use an expression to signify "do nothing"? I can't use the gui condition connector due to checking the condition inside of a column for "update a row in a table connector"

Hi @kgreen8790,

could you please rephrase? 

--------------------------------------------------------------------------------------
Contact me if you are interested in custom Power Automate development.

In the originally accepted solution the author stated to leave the "No" window blank to solve the "do nothing if false". Due to my use case I can not use the "Condition" connector in the power automate GUI. I'm wondering if there is a way to achieve the same result with a written expression. Currently if I leave the third parameter blank on my written if statement expression I get an error saying "if requires 3 parameters, only received 2". I've tried if(equals(item(), 'X'), 'Do X', false) but in this instancte the flow actually places the word false on my spreadsheet (which is what I'm using the condition for). If I try if(equals(item(), 'X'), 'Do X',) I get the beforementioned "requires 3 parameters only received 2" error. So, in closing is there a way to express an written if statement where the false comparative simply takes no action? 

VictorIvanidze
Community Champion
Community Champion

Try to use something like tis:

if(equals(item(), 'X'), 'Do X', null)

--------------------------------------------------------------------------------------
Contact me if you are interested in custom Power Automate development.
Jmorris0923
Frequent Visitor

I am having the same issue. I have tried the following expressions with a excel data source and writing to D365. Both still clear out the data in D365. I don't want to create multiple conditions in the flow to accomplish this as I have a lot of fields that needs this logic. I have used this same expression with a Microsoft Form data source it is still works. But when I switched to an excel data source it no longer works.

if(empty(outputs('ListRows')?['Main Phone']),' ' , outputs('ListRows')?['Main Phone'])

if(empty(outputs('ListRows')?['Main Phone']),null , outputs('ListRows')?['Main Phone'])
 
Jmorris0923_0-1663258818875.png

 

If I'm reading your if statement correctly your checking if output from List Rows: Main Phone is empty, if so do nothing, if List Rows: Main Phone has value then your having it update a row in dataverse with the 'Main Phone' value. Is that correct?

 

If so you may want to try equals(outputs('ListRows')?['Main Phone'], '') rather than 'empty'. I haven't used the empty evaluator before so I'm unfamiliar with its behavior but I've used the equals evaluator to check for empty string via ' ' and have had success with this. 

Jmorris0923
Frequent Visitor

Thanks for the info. I did end up re-writing the expression a little differently to get the job done. But I do believe the null expression worked at one time as I had several flows using this format. 

The point if that this is incredibly bad coding practice. By leaving it blank anyone reading the "code" (either the "programmer" or as a reviewer) doesn't know if this is intentional or not. 

Helpful resources

Users online (2,884)