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

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.

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!

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.

Hi @mppowe ,

I think it's not a problem because I tried with an example, it worked for me.

Even if we use the number specified as a string in the comparison, it does not cause problems. But I agree Ideally we should use it in formula mode for numbers.

@jashmore  If you provide us the whole recipe screenshot we can predict what can be the issue.

Thanks and Regards,

Shivakumara Avadhani