Hi, i am using the IsNothing activity to create a condition to check if my string variable is empty or not but the if condition always enters the if-else and not if-then, no matter my variable is empty or not. For reference in the attached pic the loop always output - Decision_ + “is not empty”.
@shekhawat.arjun1307 - When its empty and going to through the else loop, what is your message box output?
Yes it is displaying - is not empty
Could you please try the below statement and update whether its working or not !!
String.IsNullOrWhiteSpace(stringVariableName)
Thanks !!
@Rakesh_Sampath It works, Thanks.
Although this thread has a solution, for people who are wondering why this did not work, here is a short explanation.
-
When you use
IsNothing(VariableString)
this will always return False. This happens becauseIsNothing
method will only work if your VariableString is a Reference Type variable i.e., you explicitly have assignedNothing
to it. See Remarks section in this link. -
When you have a Value Type
VariableString
, either theIsNullOrEmpty(VariableString)
orString.IsNullOrWhiteSpace(VariableName)
will work fine. A Value Type can also be for example an empty string (""
).
For anyone wanting to know more about Value Type vs. Reference Type
Workflow for reference: IsNothingVs.IsNullOrEmpty.xaml (7.8 KB)
Hope this clears some doubts.
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.