5

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.

Joe Eng
  • 1,072
  • 2
  • 15
  • 30
  • Can you try something like that :`@length(if(equals(triggerOutputs()?['headers']?['SAS-Uri'], null), '', triggerOutputs()?['headers']?['SAS-Uri']))` – Thomas May 04 '18 at 23:10
  • @Thomas - tried it but no luck. Are the ?'s like null conditional operators in c#? – Joe Eng May 07 '18 at 16:28
  • Yes the ? Is a null propagation operator – Thomas May 07 '18 at 19:54
  • 1
    The error message said that another action failed. Have you check your workflow ? It sounds like a child action is failing – Thomas May 07 '18 at 19:55
  • 1
    Ah, that was the problem. I assumed it was the condition action causing the problem, but it was a child action. I need to pay better attention to the message. Thanks! – Joe Eng May 07 '18 at 20:31
  • Good to here. you should edit your question or close it if it is not really relevant for the community. – Thomas May 09 '18 at 06:21

3 Answers3

6

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.

Craig Eddy
  • 889
  • 1
  • 6
  • 17
  • Okay, here's what I've got now, but still getting the same error. This is a http trigger LA and I'm getting the value from the headers, btw. I've initialized the variable like so: `coalesce(triggerOutputs()['headers']['SAS-Uri'], '')`. Then in my condition I've got `length(variables('SasUri'))` with a greather than 0. – Joe Eng May 04 '18 at 15:13
  • Problem here is if you get null in the string that it will get an error. So be careful. – Dino.F May 28 '21 at 10:55
1

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

whatever
  • 2,492
  • 6
  • 30
  • 42
0

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.

Deepak Shaw
  • 461
  • 3
  • 6