cancel
Showing results for 
Search instead for 
Did you mean: 

Condition is false but step is still executed

jashmore
Deputy Chef II
Deputy Chef II

Hi - I need help please on a strange situation...

I have a simple IF condition checks if an integer variable is greater than zero.  When I run the job I can see that integer is in fact zero, and that the condition evaluates to false, but it is still executing the steps within the condition.   

As a test to make sure the steps were truly nested within the condition, I changed the condition to if true equals false, which evaluated to false as expected, and skipped the contained steps, as expected.  

I've also tried not equal to zero > condition is false as expected but the steps are executed.  And just for fun equal to zero > condition is true as expected and steps are executed as expected.  

Has anyone seen this before where it goes into the steps even when the condition fails?  Thanks in advance!

 
 

 

3 ACCEPTED SOLUTIONS

gary1
Executive Chef III
Executive Chef III

I think I need to see more of the recipe to get a better idea of what's happening. Here are some thoughts:

  1. Dupe the recipe and re-run it. This sometimes fixes "illogical" behavior.
  2. Add a logger inside the conditional to capture RowCount. Something funky is happening there. Do you have another RowCount variable somewhere in the recipe?
  3. Try recreating RowCount as a different variable. Maybe a variable schema thing?
  4. If this recipe segment is within a loop, there might be something else happening, but I can't really see.

View solution in original post

mppowe
Executive Chef I
Executive Chef I

The first thing that came to mind to me was a data type issue, like comparing a string against a number.  But your screenshots show the variable is an integer, and the IF condition always says ABC.  But for chuckles, maybe try changing the IF to be formula mode and see if RowCount > 0 as the formula (and the condition just becomes "is true") and see what does?  You can also use some logger steps to evaluate formulas to see how they wind up, like RowCount = 0, RowCount = "0", etc.

View solution in original post

Thanks for your help - it's working as expected now.  Yes, it's running within a loop and I think you were right to suggest that as the issue. The variables RowCount and RowCount2 were just to simplify the situation.   The underlying issue I think was that within the loop I was doing a batch insert from a variable list into a SQL Collection, including list creation if needed, (and clearing both the variable list and SQL collection on each loop).  I was then querying the SQL Collection and it was the ListSize of the query results that was giving inaccurate results.  I moved the SQL Collection creation outside of the loop - I still batch insert and delete within the loop and it's working as expected now.   There may be some other nuance that I affected in my experiments too that I'm missing, but I'm not going to mess with it any more 🙂  Thanks again!

View solution in original post

8 REPLIES 8

gary1
Executive Chef III
Executive Chef III

Can you share how the condition is written and maybe a screenshot of the input and output?

3 Define RowCount2 Variable.png2 Define Condition.png1 Define RowCount Variable.png6 Inspect RowCount2.png5 Inspect Condition.png4 Inspect RowCount.png

The screenshots didn't upload in order unfortunately, but there are 6 screenshots.  3 screenshots defining the RowCount variable, the condition and the RowCount2 variable... and 3 screenshots inspecting RowCount, the condition and RowCount2.  Thanks for taking a look!

gary1
Executive Chef III
Executive Chef III

Is this running within a loop?