Skip to content

Instantly share code, notes, and snippets.

@iaindooley
Last active May 3, 2019 07:18
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/86df7a00c2052c9af7cfad948244a9a5 to your computer and use it in GitHub Desktop.
Save iaindooley/86df7a00c2052c9af7cfad948244a9a5 to your computer and use it in GitHub Desktop.
Tally custom fields
function tallyCustomFieldsForList(notification)
{
var notif = new Notification(notification);
notif.movedCard();
tallyCustomFieldForList(notif.listBefore());
tallyCustomFieldForList(notif.listAfter());
}
function tallyCustomFieldForList(list)
{
var total = 0;
list.cards().each(function(card)
{
total += parseInt(card.customFieldValue("Something to Tally"));
});
if(parts = /(.+) \([0-9]+\)/.exec(list.name()))
var base_list_name = parts[1];
else
var base_list_name = list.name();
list.setName(base_list_name+" ("+total+")");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment