Not equal (<>) not working

The not equal operator is not working. I have an if activity testing for not equal and it always go to the else statement. The right side of the equality doesn’t matter, whether I use “1” or any other number, it always go to the else activity.

If, however, I use “=” rather than “<>”, the “then” activity is executed, again doesn’t matter what number I use on the equality.

I tried both in_TransactionItem.toString <> “1” and in_TransactionItem <> “1” (toString removed), and not working.

Would someone please confirm that <> is not working instead of suggesting other ways to test the inequality/equality?

image

Hi @jffeudo86

Use not intransactionitem.ToString<>“1”

Thanks
Ashwin.S

Hello @jffeudo86
Use !string.equal operators

Thanks

2 Likes

Use not intransactionitem.ToString<>“1” doesn’t work. It works the way I described to be a problem.

“Use !string.equal operators” — So basically, the “<>” doesn’t work (or maybe even “=”). This question has come up a few times and no one specifically said it doesn’t work. Only suggestions on what to use but not necessarily categorically saying “<>” doesn’t work. ("=" doesn’t work either).

To the developers, “<>” is simple and easy to understand, there’s no need to go away from it nor deprecate its use.

2 Likes

Hi @jffeudo86

here Then block is executing?
pls check by writing a message box and let me know.

Hey @jffeudo86,

I have tried this by putting message boxes and it is working fine for me.

If i assign “1” and then compare it goes to the else which is correct and if i assign it “2” it goes to the then part which is also correct.

1 Like

The else block is executing regardless of the value of in_TransactionItem (be it “1”,“2”,“3”, etc.) If I change it from “<>” to “=”, the “then” block executes, again regardless of the value of in_TransactionItem.

It only works if I use string.equals operator. So hopefully other people will find this post and know that “<>” or “=” doesn’t work.

Thanks @amarasto. It doesn’t work for me. You could also search for “not equal” and the question has come up at least a couple of times.

but why it is working for me.:thinking:

1 Like

Can you pls check is there any variable named as in_TransactionItem?
in some times we accidentally create variable and argument with the same name in that case it picks variable instead of argument so every time else will execute.

1 Like

Thanks, Karun. No, there is none.

Its work for me.

Basically <> or = are to marched object reference. And equals is to match value. Still in my testing behavior of <> and equals is same. It is working as expected.

2 Likes

have you created this argument in outer or inner scope by mistake? please do a check to ensure you do not have this variable declared anywhere else in the solution.

Very valid point @Karun . If there is a variable with same name then that variable gets preference.

I could reproduce the issue mentioned in OP only by using a variable of same name which contains a different value.

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.