06-26-2024 01:30 PM
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!
Solved! Go to Solution.
06-26-2024 07:52 PM
I think I need to see more of the recipe to get a better idea of what's happening. Here are some thoughts:
06-27-2024 05:42 AM
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.
06-27-2024 07:55 AM
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!
06-26-2024 07:52 PM
I think I need to see more of the recipe to get a better idea of what's happening. Here are some thoughts:
06-27-2024 07:55 AM
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!
06-27-2024 05:42 AM
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.
06-27-2024 06:30 AM
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