Joe Eng
Joe Eng

Reputation: 1214

Azure Logic App - simple condition to check for empty string variable fails

Solved

Issue was due to error in child action as Thomas pointed out, not the way I was checking the variable value.


I've got a variable that's been initialized earlier in the LA. Later on I'm trying to check if the variable is empty using a condition.

enter image description here

Here's the output from the run history:

enter image description here

enter image description here

It looks like the variable is an empty string at this point, however the condition fails without any helpful information.

enter image description here

I've also tried null or wrapping the variable in the empty command and comparing to true/false. All gave the same failure.

Upvotes: 5

Views: 27925

Answers (3)

Deepak Shaw
Deepak Shaw

Reputation: 667

I have done this in 2 step process: Step 1: In compose connector If(equals(items('For_each')?['Email'],null), '',items('For_each')?['Email'])

Step 2: in Condition connector length(outputs('Email-EmptyOrNull')) is equal ZERO?

It works for me.

Upvotes: 0

whatever
whatever

Reputation: 3637

For me placing an empty string between double quotes in a condition action to recognize the empty string works well. Be aware however that once you enter the empty string in the condition action and save your logic app, if you afterwards go back in the designer and reopen the condition action the empty string enclosed in double quotes ("") is not displayed anymore.

enter image description here

Upvotes: 1

Craig Eddy
Craig Eddy

Reputation: 959

You can use the length function in the expression. I've found it helpful to also coallesce the value to an empty string before checking length.

Upvotes: 6

Related Questions