cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Rfla
Level 10

Flow advanced condition?

Hi, I have 2 similar steps in the same flow to check a sharepoint field/column for typical email characters:

 

First step:

@and(not(empty(triggerBody()['SHAREPOINTFIELD'])), not(contains(triggerBody()['SHAREPOINTFIELD'], '.')))

If true send mail else nothing

 

Second step:

@and(not(empty(triggerBody()['SHAREPOINTFIELD'])), not(contains(triggerBody()['SHAREPOINTFIELD'], '@')))

 If true send mail else nothing

 

If I add an a liste element that is empty(null) for that specific SHAREPOINTFIELD I get an error on the first condition but not the second? Any suggestions.

I have tried to "merge" them into on but that did not help.

1 ACCEPTED SOLUTION

Accepted Solutions
Microsoft kkurni
Microsoft

Re: Flow advanced condition?

@Rfla after looking at your error message again, it seems the error is in "Contains" function not the empty function.

 

As you have the first step which just checking if it is empty, the empty function also checking the null.

 

But now the issue is @and condition will gather both results (Empty & Contains condition results) instead of by pass the second condition like other programming language (e.g C# or java).

 

So in this case, if it is null, this contains will throw an error.

 

To solve this issue, you can change your function to use coalesce directly without and.

@contains(coalesce(triggerBody()['SHAREPOINTFIELD'], ''), '.')

 

coalesce function will give default value if triggerBody()['SHAREPOINTFIELD'] return null.

and Contains function will always evaluate with non null value.

 

Let me know if you still have an issue.

View solution in original post

9 REPLIES 9
Rfla
Level 10

Re: Flow advanced condition?

In other words I am trying to check that its not empty and missing a specific character.
If the field is empty the flow should skip these conditions.
Its when the field is empty that it fails.

Microsoft kkurni
Microsoft

Re: Flow advanced condition?

Do you mean this is the first condition that pass ?

not(empty(triggerBody()['SHAREPOINTFIELD'])),

 

and the contain condition is failing ?

 

CC @SameerCh

Rfla
Level 10

Re: Flow advanced condition?

Thanks for your feedback, its the first condition that fails. The one linked to step number 1(entire condition). The second condition in step 2 is skipped as it should?

 

Error:

error.png

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Conditions:

Untitled3.png

Microsoft kkurni
Microsoft

Re: Flow advanced condition?

It seems your condition only evaluate not Empty, but the condition consider null is not empty as well.

So it send the value null to the action which end up getting error.

 

Does the value from the trigger is actually null ?

If it is null, it should does nothing instead.

Rfla
Level 10

Re: Flow advanced condition?

Correct, since both condition check the same, except some minor string diffrences both conditions should skip it right?. But only one of the conditions skip the flow from triggering? There is one more condition before this, that only checks for empty. That I dont think is relevant.

 

Sceenshot:

 

Untitled2.png

PS: why does the last condition work when it checks for the same empty field/null as well as a string value?

Microsoft kkurni
Microsoft

Re: Flow advanced condition?

 
Microsoft kkurni
Microsoft

Re: Flow advanced condition?

 
Microsoft kkurni
Microsoft

Re: Flow advanced condition?

@Rfla after looking at your error message again, it seems the error is in "Contains" function not the empty function.

 

As you have the first step which just checking if it is empty, the empty function also checking the null.

 

But now the issue is @and condition will gather both results (Empty & Contains condition results) instead of by pass the second condition like other programming language (e.g C# or java).

 

So in this case, if it is null, this contains will throw an error.

 

To solve this issue, you can change your function to use coalesce directly without and.

@contains(coalesce(triggerBody()['SHAREPOINTFIELD'], ''), '.')

 

coalesce function will give default value if triggerBody()['SHAREPOINTFIELD'] return null.

and Contains function will always evaluate with non null value.

 

Let me know if you still have an issue.

View solution in original post

Highlighted
Rfla
Level 10

Re: Flow advanced condition?

Thanks 🙂

Helpful resources

Announcements
firstImage

Power Platform Online Conference

Join us for the first ever Power Platform Online Conference!

firstImage

Coming Soon: T-shirt Design Contest

Keep your eyes open for our upcoming T-shirt design contest!

firstImage

Incoming: New and improved badges!

Look out for new contribution recognition badges coming SOON!

firstImage

New & Improved Power Automate Community Cookbook

We've updated and improved the layout and uploading format of the Power Automate Cookbook!

thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

Top Solution Authors
Top Kudoed Authors
Users online (6,561)