Last active
February 16, 2019 05:40
-
-
Save iaindooley/20a4f27a841aa94673c7ffad5bd026c1 to your computer and use it in GitHub Desktop.
Detect duplicates
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 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