How can i optimize the if condition as post 15 or more condition sometime it works and somitime not

Hi

i am using if condition as i have multiple or c0ndition used post 15 or conditions sometime it works and sometime it not
how can i optimize and use this

ex. country.equals(“Japan”) or country.equals(“Nepal”) or…

HI,

How about using array as the following?

image

Regards,

1 Like

@Yoichi when i added 25 country name as {“C1”,“C2”, …} its not working as expected even in array

HI,

Can you elaborate? If possible, can you clarify input data etc?

Regards,

@Yoichi for example i want to add the country name in email that i am creating

sampleemail+Countryname@gmail.com

so i created an Array and added all countries to that array {“C1”,“C2”, …}

but it works for some and does not for others not sure why initial is used if condition to check each country in if condition now i am using arr.contains(Country)

Input is coming from Sharepoint sheet that i correct

I don’t understand your requirement 100%. However, if you want to check if one of country array is included in the email address, the following will work.

arrStr.Any(Function(s) System.Text.RegularExpressions.Regex.IsMatch(email,s,System.Text.RegularExpressions.RegexOptions.IgnoreCase))

Does this work for you?

Regards,

my requirement is change the flow when a country name matches then change the flow path accordingly @Yoichi

previously it was working for 16 but as we add it not working for other

HI,

If possible, can you share your workflow as file?

Regards,

@Yoichi that is not possible

however let me try to put this way

Country = “Japan”
Arr = {“India”,“Japan”,“Canada”, …25+}

if arr.contains(Country)

this works but only for few rest its not working

Hi,

For now, can you check if it doesn’t contain any whitespace and/or same regarding upper/lower-case? Country.Length or Country.Trim may also help you for the former checking.

Regards,

1 Like

Remember that the check is Case Sensitive.
So perhaps write all your contries in the array in lower case, and make this check instead:

arrStr = New Array(Of String){"india","japan","canada"...}
If arrStr.Contains(country.ToLower)

Regards
Soren

@SorenB i did not sure what is the issue no space , no error in spelling

Hello @mint

Im not entirely sure what you mean.
But Case Sensitive is the difference in the SiZiNg of the different characters.

To take “empty space” into account, you would have to add .Trim

If arrStr.Contains(country.ToLower.Trim)

Regards
Soren

@Yoichi @SorenB see these all things are working fine when we have array limited but when its going beyond 15 even its not able to check if that element is there in array or not with for each its working fine but i cannot use that everywhere

ARR has that country same as it is

HI,

it may be something wrong with Studio. To isolate cause, can you try to output content of the array as the following, for example?

image

Regards,

1 Like

@Yoichi this gave all country name now separate with ,

If possible, can you share your workflow as file?

Sorry cannot
can i replace the Arr with this join condition that said it should be able to work right

i will try with let me see if it works

Hello @mint

Can you please compare your flow with my .xaml-file below?

image

Countries.xaml (8.3 KB)

Best Regards
Soren

1 Like

@SorenB yes exactly same way i have implemented but not sure what is wrong