Check if a string exists in any row of a certain column of a table

I have a table that is populated from an API GET request to Stripe (gets all customers). In the table there is a column with the title "Company_Name." In my app, the user selects a company from a dropdown and if there is no matching customer with that name I am giving the user the option to create a customer.

For example, if the company selected was "Amazon" I want to check every row in the table in the "Comapny_Name" column to see if the string "Amazon" exists. I would like to note that I am looking for a contains function rather than an equals function.

I know this is more JavaScript related than Retool, I am taking a JavaScript course right now and have been trying to do this using for loops unsuccessfully, so I am reaching out for help.

If you can post some screenshots, it will help - I think you are asking if when selecting a company name within a row?

So if I used this image as an example, I would like to check if there's any rows that contain the string "Amazon" in the "name" column. In this case, the result should be true or 1 row. My thoughts were to use a .some() method somehow but once again I am bad at JS.

Just curious why you would need to check the entire table, but instead you could check the currentRow.email.includes('companyname') within the event when selecting the company name in the dropdown...
Otherwise, you should move the select dropdown to be outside the table, so that when selected you can compare it to all of the data in the table and see if there is a match.

1 Like

My dropdown is not apart of the table, sorry I should have clarified that. It is outside the table and like you said, I am trying to compare it to all of the data in the table in the column. I am just unsure how to approach it.

What I have done is I have made a custom column that checks if the name exists in the table by comparing the selected drop down item with the name column and evaluates to either true or false, my issue is I want to pull the name where it evaluates to true.


If the test customer row was 'True' in the Client Exists column, how would I pull back the string 'Test Customer?'

Where you have 'True' replace it with selectClient.value without the single quotes - if I am reading you correctly....

I have a text box outside of the table where I need to display the 'Name' when that condition is true. Sorry my questions have been ambiguous.

Nevermind I figured it out....

let table = {{tableStripeCustomers.data}};

let clientExisting = table.filter(i => i.name.includes({{ selectClient.value }}))

return clientExisting[0]

1 Like

Glad to see you found a solution!

1 Like