Filter an item in array if it includes search term (contains) & only get first match


I’m looking for a bit of help. I am trying to get a single value from an array if the item includes a search trem. Note, it does not have to be exactly equal to, but should contain the variable.

I have the following function written: {{get(map(; “id”; “name”; title); 1)}}

I.e. to map the item ID if the name field contains the title. However, this seems to only work if the name in the array is exactly equal to the search term (title).

I have tried writing this a whole bunch of different ways but cannot seem to get it to return the relevant ID. The reason why this is important is some titles might be listed as “ABC - XYZ”, with our search term only as “ABC”. So I want to still capture the ID to this as it’s still valid.

Can anyone advise where I’m going wrong with this function?

@EnigmaXXIII Welcome to the community.
First of all, it’s always very helpfull to share screenshots. This gives a lot of context.

Anyway, yes the map() function only searches for very specific searchterm. What I could recommend is the following:

  • Iterate over your array
  • Use a filter to only continue with the item you want
  • In the filter, use the “contains” to search for something which it contains

This way you don’t have to search for something specific, it also continues if it contains the term.


@Bjorn.drivn Sorry about not posting screenshots - I will be sure to do that next time! However, your solution works perfectly, thank you so much!

As an additional, how would I go about only getting the first result if there’s multiple matches?

1 Like

No problem @EnigmaXXIII !
If you only want the first item that matches, you can do that in 2 (maybe more) ways:

1 - Check and set a variable

  • You check if a variable was set, and only continue if its not set (in this case the variable “ran”)
  • You set a certain variable when the item ran once
  • It doesn’t continue, because now it’s set

2 - You throw an error once it ran once

  • You set a variable or do whatever you want to do
  • You purposely throw an error after its done, which stops the run
  • You “commit” the error to not actually set the status of the run to “error”

If you want to try it out you can find the blueprint of the scenario here:
blueprint filter array.json (16.9 KB)

1 Like

@Bjorn.drivn thank so you very much! Genuinely appreciated. Optioon 1 in your demo works a charm.