How to reduce multiple OR conditions in IF statement

I currently have a validation using an IF statement where it conditions workflow direction if the variable “hospital_name” is equal to ‘Hospital Zambrano’. Now I need to add at least 10 more hospital names to that condition, what would be the most simplified way to be able to do it without using multiple OR conditions?
Screenshot_39

I thought about putting the list of names in a txt and creating a variable as an array with those names, but I can’t get the idea to land.

1 Like

Hello!

Is it possible to create an array:
hospitals = [“a”, “b”, “c”]

and then check:
nombre_hospital in hospitals
?

Best regards

2 Likes

or you can

  1. put the list of names in a txt file
  2. read txt file and save it in a variable
  3. use activity text found to check the condition

Best regards

2 Likes

Hi Mikhail,
For the last option, the list of names in a txt file, should be separate by coma, or like a column list?

1 Like

Also another question Is it possible to create an array from data in a excel sheet?

2 Likes

Hi @Yoshi,

I think you can put the list of the names in a txt file, using comma or like a column list.
When you read the txt file, you will get ONE variable (with the whole text in it).
And then you can use activity text found to find the certain text in it.

You can also use split function in javascript, for example:

  1. read text file - save the results in variable results_text
  2. split variable results_text, using split function in javascript. In this case you need to select a separator in function split. As a result you will get an array
    // results_array = results_text.split(“,”)

Regards,
Mikhail

1 Like

Hi @Yoshi,

I think it is possible to create an array from data in a excel sheet.

  1. you create a variable x = [ ]
  2. you read data from excel sheet
  3. you can make a loop to select data, you need exactly
  4. you can add data to the end of array using x.push(“value1”);
    (in this case you can use activity “execute js code”)

Regards,
Mikhail

1 Like

Hi Mikhail
Thanks a lot for your help

2 Likes

Hi @Yoshi
You are welcome!

1 Like