Find if a list has an item from another list

Hi! I am trying to compare two lists, each with a varying number of items. One list is derived from an API, for example: Diphenhydramine citrate, Ibuprofen. Basically, when the user inputs items into a list of allergens, I want to figure out if the item is in the list or not. For example, if I input Ibuprofen, the code should be able to find the variable in the API list. Thanks!

It sounds like you’re wanting to build a search filter. We’ll need a little more information here.

For the list item Diphenhydramine citrate, would the user only be able to enter “Diphenhydramine citrate” as the search term or would you want that item to be found if the user enters “citrate”? What about “CITRATE”? What about if they type “ate” and 15 list items have that search term? Should it display all 15 or just the first result?

If a search filter is what you’re wanting, I suggest Googling filter Thunkable search results to find some good starting points. You’ll probably need to loop through the list items and use the Does contain block to check for the presence of the search term in each list item.

I believe I understand your needs. I think if you used the “for each item “J” in the list” block that can be found at the bottom of the control tab.

The example above calls the API, and then checks each item within the list the API provides to see if it matches the item entered into the search box.
Hope this helps


Here is an image of some of my code… the problem is that, for example, if Ibuprofen is in the list, and also in the ingrlist, the text box should go to “WARNING”. But, even though this is true, (Ibuprofen is added in a lest in a list viewer on a seperate screen), this doesn’t happen.

A couple things:

  1. The does list contain block returns a value of true or false so the = true block is not necessary.
  2. What is the value of the green response block? You can assign it to a text input’s text so that you can copy it and paste it here. Make sure to format it using the </> button in the forum toolbar at the top of your post.
  3. What is the value of cloud variable List? Do the same as for #2 above.