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

studio

#1

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??


#2

@sams

try countryarray.contains(“Canada”)

searchStringinArray.xaml (5.7 KB)

thanks,
pathrudu


#3

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


#4

thanks for reply @pathrudu,

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


#5

@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


#6

@pathrudu

country.xaml (13.6 KB)

please check this one


#7

@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?


#8

@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.


#9

@sams

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

thanks,
pathrudu


#10

@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 .


#11

@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.


#12

@pathrudu

Please review this one.


#13

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.


#14

@pathrudu,

Yes, there is trim the value in location variable.


#15

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


#17

as of now i can’t i am in office


#18

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


#19

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


#20

@sams In that file some activities are missing bro.