Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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