Skip to content

Instantly share code, notes, and snippets.

@iaindooley
Last active February 16, 2019 05:40
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/20a4f27a841aa94673c7ffad5bd026c1 to your computer and use it in GitHub Desktop.
Save iaindooley/20a4f27a841aa94673c7ffad5bd026c1 to your computer and use it in GitHub Desktop.
Detect duplicates
function detectDuplicates(notification)
{
var notif = new Notification(notification);
//only proceed if a new card was created
var new_card = notif.createdCard();
//only proceed if a card already exists on the same board with the same name
var existing_card = new_card.board().card(new_card.name());
//append the new card's description to the existing card, and attach the new card as a link
existing_card
.setDescription(existing_card.description()+"\n----\n"+new_card.description())
.attachLink(new_card);
//post a comment to the new card informing the member it's a duplicate, link to existing and archive the card
new_card
.postComment("@"+notif.member().name()+" duplicate, here's the original: "+existing_card.link())
.archive();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment