How to assign a boolean value for a string if it contains specific texts

Hi, I would like to know how can I assign a boolean value to a string that contains specific texts?

Specifically, I want it to be like this:
when the string contains “Yes” return a boolean value of True
when the string contains “No” return a boolean value of False.

Sorry if this sound too easy I am quite new to UiPath automation, I just hope to get some assistance on this

Hi @Ben_siu

  1. Use If condition


If the String is Yes it will Go to Then part

If the String is No it will Go to Else part


1 Like

if you want to have it concise, you can use inline if in Assign activity. If YourString will be “Yes”, then it will assign True to YourBool, if YourString will be anything else, it will assign False.


1 Like

Please use assign activity
on left side put bool variable
right side put string operation like this


Hello @Ben_siu , Try this
YourString=“The Answer is Yes”


it will return as “True”, If there is no "Yes in your string, it will returns “False”

1 Like


Try inline if condition like below-

if(mystring.contains(“Yes”), “TRUE”, if(mystring.contains(“No”),“FALSE”,‘’ "))


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