How to check array value and string is equal in uipath?

Hi,

I have an array like countryarray = {“US”,“Europe”,“Canada”,“Australia”,“Singapore”,“United Arab Emirates”}
and string like country = “Canada”

I want to check countryarray contains country string.
any solution for this??

1 Like

@sams

try countryarray.contains(“Canada”)

searchStringinArray.xaml (5.7 KB)

thanks,
pathrudu

Hi @sams,

Use countryarray.Contains(country). you can put this statement inside an IF to check whether that country exists or not.

Please let me know if doesn’t work.

Regards,
Vikas

1 Like

thanks for reply @pathrudu,

I had tried like countryarray.contains(counrty).
I have object in contains() argument.

@sams
you might be getting the object from for each? if yes you can change type argument in foreach activity to string from object and can use directly or you can use country.tostring

please check and let me know

@pathrudu

country.xaml (13.6 KB)

please check this one

@sams
are you getting error at final message box? i can’t run this process as i don’t have access to Linkedin.
but itried with different website i am getting perfect output. what issue are you facing here?

@pathrudu
In final message box it add or subtract the score.
if array contain the location then it add other wise it subtract the value

condition every time goes in else part.

@sams

use this workflow, it should work.
country_v1.xaml (13.5 KB)

thanks,
pathrudu

@pathrudu

No, its not working,

In array United Arab Emirates is there and location is also United Arab Emirates value,

it return false in message box .

@sams

can you please share the screenshots of your message boxes, because I could able to run it properly
you are taking last value of your array please check there might be “.” included.

@pathrudu

Please review this one.

did you used the file which i shared to you? please trim your location variable after assigning array variable so that all the spaces will be removed.

@pathrudu,

Yes, there is trim the value in location variable.

@sams
sorry, I am helpless as it is working on my machine properly

as of now i can’t i am in office

@samsseq.xaml (6.3 KB)
Check this it will work

1 Like

thankx @Manjuts90

can you pleae try out this:- https://forum.uipath.com/t/how-to-check-array-value-and-string-is-equal-in-uipath/28384/6?u=sams

@sams In that file some activities are missing bro.