I was perusing the Trello Community and found someone looking for the following:
I provided an answer there, which you can check out. In this post I’m going to provide a more detailed walkthrough, with screenshots :)
What challenge are we solving?
The idea is to search a subset of Trello boards for a card before looking on another board. In this user’s case, there are 5 boards to search before finally looking on a Sales board (if nothing was found on those other boards).
There are various ways to approach this, including having a monstrous Zap with multiple nested paths (which is not ideal). Here’s how I tackled it.
What are we building here?
I’m using 2 Zaps that will run at the same time, triggered by the exact same thing.
Zap 1
When triggered this Zap will use Looping by Zapier to do the following:
- Use a comma-separated list of Trello board IDs to search for cards in each
- Check a filter to maker sure that a card was found, before moving on to...
- Add the card ID to a key in our Storage app (quickly store and retrieve small values of data)
Zap 2
When triggered, this Zap will be delayed for 1 minute in order to give Zap 1 time to check all of the first boards. Then…
- Check that key in Storage to see if anything was added (meaning a card was found)
- Go down 2 paths:
- Path 1: If a card was found, then update that Trello card
- Path 2: If NO card was found, search the last board then update THAT Trello card
Let’s walk through the process
Zap 1
Trigger: Whatever you've got set up
This can be any app you choose. In my example I’m using a webhook so I can send the same information to 2 Zaps.
Action: Looping (an app we have in beta)
For our purposes, Create Loop From Text will work fine.
Then we add the IDs of the boards we want to search, separated by a comma. An easy to way to get that is by doing the following in Trello while on the page for your desired board:
Then you add those IDs here (I’ve only got 2 in my example, for simplicity’s sake):
Loop Action #1: Trello — Find Card (using the boards you specify)
Map the field from the Looping step into the Board field of your Trello step.
Let’s zoom out to see that whole step:
You can skip the test of the Trello step if you want, but in order to set a value in Storage (upcoming step) you’ll need to find a card.
Loop Action #2: Filter: Only continue if you find a card
For the filter, you can use this field then see if the value is “true”:
Loop Action #3: Storage: Set a value in our data storage app, with the key being the name of the card and the value being the ID of that card.
For the Key, choose the field that you’re using in the Trello search step, that’s provided by your trigger step.
For the Value, map the field from the Trello search step that corresponds to the card’s ID, as seen below.
What did we do in this Zap?
We're triggering the Zap and looping through the boards you specify, looking for a card with the name that comes through that trigger step and if found, we set a value in our Storage app (to be retrieved in Zap 2).
Zap 2
Trigger: The exact same as Zap 1
Use the same trigger so that both Zaps will run at the same time.
Action: Delay for 1 minute (this gives the other Zap time to look for the card in the first 5 boards)
Action: Storage — Look for the value
Use the same field here that you used in Zap 1, for the Key in Storage.
Paths: We'll have 2 paths you can go down, based on conditions we set.
Paths use conditions just like Filter steps do. If you’ve used Filters before, then this should be pretty straightforward.
Path #1: Only continue if a value was found
This means that the first Zap was able to find a card and therefore create a value in Storage.
Action: Trello — Update Card (using the card ID you added to Storage)
Map the Storage field that contains the Trello card’s ID.
Path #2: Only continue if NO value was found
This means that nothing was added to Storage, because no Trello card was found in Zap 1. So we’ll now check that last board and update the card there.
Action: Trello — Find Card (using info from this Zap's trigger step)
Since the card wasn’t found on one of those first boards, I’m going to check that last board.
Action: Trello — Update Card (using the ID of the card you find)
Map the field from the Trello search step, and then configure whatever you want to update on the card.
What did we do in this Zap?
We triggered on the same thing that runs Zap #1, waited 1 minute to prevent this Zap from running before all other boards were checked, then ran through 2 paths. One path used the value we set and updates the card, while the other searches that Sales board then updates the card that's found.
Wrapping Up
Whew! Hopefully you were able to follow along. I know it’s a lot, especially if you’ve never used Storage, Paths and/or Looping. This technique could apply to things besides Trello boards/cards. In a project management app, you could look in certain projects before checking elsewhere, for example. Until next week, happy automating!