Good afternoon, I tried switch statement and in the expression I am trying to do nested If statement like:
If (gender=“F”, If(Married, “Mrs”, “Mr”) , “Mr”).
For the same I have created two variables gender and Married of type String. While I am trying to run code its giving following error:
The workflow has validation errors. Review and resolve them first.
System.Activities.InvalidWorkflowException: The workflow has validation errors. Review and resolve them first. —> System.Activities.ValidationException: Compiler error(s) encountered processing expression “If (gender=“F”, If(Married, “Mrs”, “Mr”) , “Mr”)”.
Option Strict On disallows implicit conversions from ‘String’ to ‘Boolean’.
I followed the instructions in UI Path Best Practice Guide, please help me solve the issue.
Married would need to be a Boolean type like True or False. Have you verified that? If you want it to be a string, then change it to something like Married=“Y” or similar.
I tried changing the type to boolean as well then following error is shown:
The workflow has validation errors. Review and resolve them first.
System.Activities.InvalidWorkflowException: The workflow has validation errors. Review and resolve them first. —> System.Activities.ValidationException: Compiler error(s) encountered processing expression “Married”.
Option Strict On disallows implicit conversions from ‘Boolean’ to ‘String’.
That error shows that you have a field that is supposed to be a string but is a Boolean. Also check that your Switch type is set to String.
Could you provide a screenshot of the activity with the validation error and the details around that activity? That would make it easier to solve your issue.
The Expression looks correct. Have you tried showing what gender and/or Married.ToString is in a message box? It’s possible gender didn’t get stored correctly.