Skip to content

Instantly share code, notes, and snippets.

@iaindooley
Last active October 1, 2020 01:17
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/5d5de3d94efe4ff5384f05d67fa3be63 to your computer and use it in GitHub Desktop.
Save iaindooley/5d5de3d94efe4ff5384f05d67fa3be63 to your computer and use it in GitHub Desktop.
Create transaction from linked card
function createTransactionFromLinkedCard(notification)
{
//trigger when a card is attached to another card
var notif = new Notification(notification);
var attached = notif.attachedCard();
var attached_to = notif.card()
//remove the attached card
attached_to.attachment(attached.link()).remove();
//Create a new card in the Transactions board and attach each card
var target_list = new Trellinator().board("Transactions").list(/Inbox.*/i);
var transaction_link = Card
.create(target_list,attached.name()+" with "+attached_to.name())
//attach each of the businesses involved to the transaction
.attachLink(attached.link())
.attachLink(attached_to.link());
//notify the user so they can come and fill out details of the transaction
.postComment("@"+notif.member().name()+" new transaction created, please add the category label and amount")
.link();
//Link to the newly created transaction card from
//each of the original business cards
attached.addChecklist("Transactions",function(cl)
{
cl.addItem(transaction_link();
});
attached_to.addChecklist("Transactions",function(cl)
{
cl.addItem(transaction_link();
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment