If condition not working not equals

Hi All, I am using http request to perform rest api get calls storing json deserialize values comparing that using if condition status <> “LIVE” Or status <> “RESERVED”. Seeking your expertise.

Hi @Sathish_Ashokan

Could you please let me know the value that you get in status variable ?

Hi @Sathish_Ashokan

Can you check the value of Status in Debug mode, and what is the exact condition that you wanna check?

And my guess is you want to check that the status shouldn’t be LIVE or RESERVED

you should be using

Status <>“LIVE” and Status <> “RESERVED”

That would solve your problem.

Attached Solution:

Explanation: In case of Not equals to you would have to explicitly check against each value and hence you should be using AND condition instead of OR.

Deserialize JSON output → Sts ==> JObjMCN(“organizationInformation”)(“status”).toString

Part of Rest API call response only.

Please check the above solution. Instead of OR Condition, go ahead with AND condition and see if that is what you want to achieve.
Thanks

@Sathish_Ashokan

Is sts your variable ? you are deserializing status key and storing it in sts ?

If yes try checking below

sts.Trim.ToLower <> “live” and sts.Trim.ToLower <> “reserved”

“not equal A or not equal B” will always be true. If the value is A then it’s not equal B. If the value is B then it’s not equal A. OR means it’s true if either expression is true. Change it to AND instead of OR. Then it will mean the value is NEITHER A nor B.

not working also :frowning: i tested using message box it is returning live only but if condition not working madam

@Sathish_Ashokan

Could you please share your requirement ? Please check if your condition matches your requirement.

  1. If sts is not equal to live or sts is not equal to reserved, you would like to execute the “Then”
    part of the if condition is it? if yes, then check the below condition too

        not (sts.Trim.ToLower.Equals("live") or sts.Trim.ToLower.Equals("reserved"))
    
  2. If your sts value is ‘live’ and you would like to execute the “then” part of the if condition then
    please use below:

      sts.Trim.ToLower.Equals("live") or sts.Trim.ToLower.Equals("reserved")
    

I hope it helps!

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