cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Rfla
Kudo Kingpin
Kudo Kingpin

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

@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
Kudo Kingpin
Kudo Kingpin

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.

Do you mean this is the first condition that pass ?

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

 

and the contain condition is failing ?

 

CC @SameerCh

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

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.

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?

 

 

@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

Thanks 🙂

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 (47,925)