Last active
May 3, 2019 07:18
-
-
Save iaindooley/86df7a00c2052c9af7cfad948244a9a5 to your computer and use it in GitHub Desktop.
Tally custom fields
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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