Skip to content

Instantly share code, notes, and snippets.

@iaindooley
Created April 19, 2019 23:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iaindooley/dba84f2792fba2ee97dd8bbb2b916dc5 to your computer and use it in GitHub Desktop.
Save iaindooley/dba84f2792fba2ee97dd8bbb2b916dc5 to your computer and use it in GitHub Desktop.
Search all boards and cards by custom field
function searchAllBoardsAndCardsByCustomField(notification)
{
var field = new Notification(notification).changedCustomField("Query");
new Trellinator().boards().each(function(board)
{
ExecutionQueue.push("findMatchingCustomFieldCards",
{card_id: field.card().id(),board_id: board.id(),field_value: field.value()},
"findMatchingCustomFieldCards-from-searchAllBoardsAndCardsByCustomField-"+board.id(),
Trellinator.now());
});
}
function findMatchingCustomFieldCards(params)
{
var card = new Card({id: params.card_id});
var board = new Board({id: params.board_id});
var field_value = params.field_value;
board.cards().each(function(card_loop)
{
if(card_loop.id() != card.id())
{
board.customFields().each(function(field_loop)
{
if((card_loop.customFieldValue(field_loop.name())) &&
(card_loop.customFieldValue(field_loop.name()).indexOf(field_value) > -1)
)
{
card.addChecklist("Results",function(list)
{
list.addUniqueItem(card_loop.link());
});
}
});
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment