Switch Statement not working

Hi All,

I have a question regarding a switch statement which is not working. I have switch that checks the following: 

Condition 1: 

Operation=Entities.ValidOperations.OR and (Operand1="True" or Operand2="True")

Condition 2: 

Operation=Entities.ValidOperations.OR and (Operand1="False" and Operand2="False"


When I run the debugger it shows the following

This would mean that the first part of the switch is True (Operation = "OR". The label of the Entities.ValidOperations.OR = OR) and the second part of the switch is true for condtion 1. 

Nevertheless it is always taking the otherwise path meaning the rest of my logic is always ignored. Does anybody know what causes this or had any experience with a similar problem?


Thanks in advance. 

Regards,
Max

Solution

Hi Max,


Can you confirm the type of variable Operation is a ValidOperationsId?


Because if it is a text, then when you are doing this comparison:

Operation=Entities.ValidOperations.OR

you are comparing a text (variable Operation) and a ValidOperations Id (a record from the static), hence the problem.


Cheers,

João


Solution

João Marques wrote:

Hi Max,


Can you confirm the type of variable Operation is a ValidOperationsId?


Because if it is a text, then when you are doing this comparison:

Operation=Entities.ValidOperations.OR

you are comparing a text (variable Operation) and a ValidOperations Id (a record from the static), hence the problem.


Cheers,

João


 

Hi João, 

Operations is a text field. I already thought this might be the problem so I have tried to do this: 

Operation="OR" and (Operand1="False" and Operand2="False")

This is not working either though.


Fixed it! 

@Joao Your remark got me thinking. I completely missed this part while looking right at it and trying some things that should have work (I think haha). 

Fixed it with another Local Variable and two IF statement to check the operation and rewrite it to the ValidOperationsId. 

This works! Thanks for your reply