string.Contains("someValue") method returns false even though string contains "someValue"

Hello all,

I’m trying to check if Get Text value contains “2020” in string result, but it returns false each time.


Is there any other way to check if these strings contain “2020”?

Thanks in advance!

Hi @bp777
Variables created in the output field of Get Text activity are of type GenericValue.
Can you please make sure your output variable is of type String or that you are comparing with the String value, not the GenericValue.

I have converted output variable as String, but getting same result.

Can you please give more details about

  • where are you getting text from?
  • what is the output if you print using Write Line or Log Message?

What are you trying to do exactly with the data. If the strings are all date values and you are trying to confirm they are the current year, perhaps extract the year from the datetime variable instead of looking for a string in text.

1 Like

I am getting text from this table, each string I need to check is a row at the table.


Output is alright, for each row(string I need to check) writes good values(14:00:00, 14:00:00, 16/10/2020 09:30:00, etc.) but still, .Contains() method returns false when I’m checking whether or not row contains “2020”.
Not sure why.

Given the result, I can decide if I will use that row or not.
If row doesn’t contain “2020”, I will not write that row into the excel sheet.

Can you please print the variable which your are checking just before checking .contains() condition and provide that here .
And also please provide the exact condition which you are checking.

1 Like

is this resolve, I am facing same issue, please help.

@amruta_pawar - Please open up a new forum query and provide the details of the code & the error you are facing with screenshot(s)…

1 Like