Skip to content

Instantly share code, notes, and snippets.

@iaindooley
Last active November 9, 2018 01:19
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/a64e2b529560202e99d33e337a9a10f4 to your computer and use it in GitHub Desktop.
Save iaindooley/a64e2b529560202e99d33e337a9a10f4 to your computer and use it in GitHub Desktop.
Move completed checklists to a card
function moveCompletedChecklistsToLinkedCard(notification)
{
var notif = new Notification(notification);
if(!notif.member().notTrellinator())
throw InvalidActionException("Only take this action for user completed checklists");
var completed = notif.completedChecklist();
try
{
var linked = completed.card().cardsLinkedInAttachments().first();
}
catch(e)
{
Notification.expectException(InvalidDataException,e);
var linked = Card.create(completed.card().currentList(),"Completed Checklists from "+completed.card().id()).archive();
completed.card().attachLink(linked.link());
}
linked.addChecklist(completed.name()+" completed "+Trellinator.now().toLocaleString()+" by "+notif.member().name(),function(new_list)
{
completed.items().each(function(item)
{
new_list.addItem(item.name());
});
new_list.markAllItemsComplete();
}
);
completed.remove();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment