Finding or looking up cards (Butler advanced topic)

Finding Other Cards

When we run a Butler command by pressing a card button, or by triggering a rule that reacts to changes on a card, the actions of the command (e.g. adding a label) happen on the card where the trigger happened. We call this card the trigger card.

Sometimes, we want our command to reach out to other cards and do things in them, or obtain information from them. We can use the find action in order to do that.

This rule links any cards emailed to the board with a pre-existing card of the same name if one exists:

when a card is emailed into the board,
find a card titled "{cardname}",
and link the cards together
  This example transmits the move of a card to a list to a card linked from it, provoking a cascading effect:
when a card is moved to list "Done",
find the first card linked in the attachments,
and move the card to list "Done"<br>
	

When we find another card, that card becomes the current card, and all actions going forward occur on that card. Variables such as {cardname}, {carddescription}, {cardduedate}, etc., will now refer to the found card, since it's the current card. We can still use variables such as {triggercardname}, {triggercarddescription}, {triggercardduedate}, etc., to refer to the content of the trigger card.

For example, each time we add a card to a certain list, we can add a link to the trigger card as an item in a checklist in another card:

when a card is added to list "Doing" by me,
find a card titled "Rollup",
and add item "{triggercardlink}" to checklist "Doing"

Card Lookups

Sometimes, we want to find another card but continue working on the current card. For this we have the lookup action. It's used exactly like the find action, but it doesn't change the current card. We can refer to the found card using variables such as {foundcardname}, {foundcarddescription}, {foundcardduedate}, etc.

This can be useful to implement lookup tables. Let's work through a couple of examples. In the first example, when a card reaches a certain list, we want to copy it to another board depending on the value of a custom field. We could create a rule like this:

when a card with custom field "Department" set to "Finance" is moved to list "Ready" by anyone,
copy the card to list "Inbox" on board "Financial Requests" and link the cards together

Because the name of the board where the card needs to be copied may be different from the value of the custom field, we would typically need several of these rules, one per value of the custom field. A better way to implement this would be to use a lookup:

  1. Create a list named, e.g. Department Board Lookup on the same board. You can also create it on a different board if you prefer to keep the lookup table separate.
  2. In that list, create a card for each department, with the name of the card being the name of the department as per the custom field values, and the description of the card containing only one line with the name of the board.
  3. In the original board create a rule like this:
when a card is moved to list "Ready" by anyone,
lookup a card titled "{{%Department}}" in list "Department Board Lookup" on board "Lookups",
and copy the card to list "Inbox" on board "{foundcarddescription}"

Now we don't need a separate rule for each department, and adding a new department or updating the routing is as easy as creating or changing a card.

Here's another example: imagine we want to set a custom field named Priority according the the value of two other custom fields, Scope and Impact. For example when Scope is 'Small' and Impact is 'High', we set Priority to 'P1', but when Scope is 'Small' and Impact is 'Low', we set Priority to 'P3'. Etc.

To do this, we would need a large amount of rules, but with a lookup we can instead create a card for each combination. We create a lookup list, and add a card titled 'Small, High' with description 'P1', and a card titled 'Small, Low' with description 'P3', etc.

Then we can have just two rules like these:

when custom field "Scope" is set by anyone,
lookup a card titled "{{%Scope}}, {{%Impact}}" in list "Priority Lookup",
and set custom field "Priority" to "{foundcarddescription}"

when custom field "Impact" is set by anyone,
lookup a card titled "{{%Scope}}, {{%Impact}}" in list "Priority Lookup",
and set custom field "Priority" to "{foundcarddescription}"

IMPORTANT: Lookup tables are not meant to provide generic database-style functionality in Trello. Creating lookup tables with thousands of cards will result in poor performance.