Skip to content

Instantly share code, notes, and snippets.

@iaindooley
iaindooley / gist:fc2dcee1feb30f6fbb2934f4d2aa93b3
Created September 25, 2021 04:22
setCustomFieldToNextChecklistItem
var checked = new Notification(notification).completedChecklistItem();
var next = checked.checklist().itemAfter(checked);
checked.checklist().card().setCustomFieldValue("Next Action",next.name());
@iaindooley
iaindooley / gist:f40f9fb431fc1109e1615dcf4e2fdadf
Created September 24, 2021 05:52
updateChecklistItemDatesBasedOnDueDate
var card = new Notification(notification).addedDueDate();
copied.checklists().first().items().each(function(item)
{
var diff = item.due().getTime() - card.previouslyDue().getTime();
item.setDue(new Date(card.due()).addSeconds(diff));
});
@iaindooley
iaindooley / gist:b70d94d908eabfc93e8ec6bc5c529fa0
Created September 24, 2021 05:19
addMemberFromEnvironment
//When a card is moved to the Doing list
var moved = new Notification(notification).movedCard(/Doing.*/i);
moved.addMember(new Member({username: ___persistence.get("Support Co-ordinator")}));
@iaindooley
iaindooley / gist:79e9b584f91846d442a4d9ad6f2018c2
Created September 24, 2021 05:15
prependNameAndAssignLabel
var created = new Notification(notification).this.convertedChecklistItemToCard();
created.setName(
created.source.card().name()+" "+created.name()
);
create.source.card().labels().each(function(label)
{
created.addLabel(label.name());
});
function createLinkedCard(notification)
{
var added = new Notification(notification).addedLabel().name();
var target = new Trellinator().board(added.name()).list(/Inbox.*/i);
var copy = added.card().copyToList(target,"top");
copy.attachLink(added.card().link());
added.card().attachLink(copy.link());
}
@iaindooley
iaindooley / gist:00f60cf86f76d5ab5448ab91ad074425
Created February 23, 2021 02:23
Copy a card and add 7 days for the year
var cardlink = "SHORTLINK";//get this from the "share" button on the card
var card = new Card({link: cardlink});
var target = card.currentList();
var prev = card;
for(var i = 0;i < 52;i++)
{
var prev = card.copyToList(target,card.name()).setDue(prev.due().addDays(7));
}
function downloadAllFiles(notification)
{
var card = new Notification(notification).addedLabel("Download").card();
var folder = DriveApp.createFolder(card.id());
card.attachments().each(function(att)
{
var file = Trellinator.downloadFileToGoogleDrive(att.link());
folder.addFile(file);
});
function sendSmsFromTrello()
{
new Trellinator().board("My Contacts").cards().each(function(card)
{
sendSms(card.customFieldValue("Mobile Number"),"Hi there "+card.customFieldValue("First Name")+"!");
});
}
//TAKEN FROM: https://www.twilio.com/blog/2016/02/send-sms-from-a-google-spreadsheet.html
function sendSms(to, body) {
function removeImages(notification)
{
var moved = new Notification(notification).movedCard("Terminado y Cumplido");
moved.attachments().each(function(att)
{
if(/.*\.(jpg|png)/i.test(att.name()))
{
att.remove();
}
});
@iaindooley
iaindooley / gist:fcd807fcdf909019be5032a564045c7b
Created September 11, 2020 12:10
Create cards from sheet
function createCardsFromSheet()
{
var vals = SpreadsheetApp.openByUrl("urlgoesbrrr").getSheets()[0].getDataRange().getValues();
var list = new Trellinator().board("My Board").list("Inbox");
for(var i = 0;i < vals.length;i++)
{
Card.create(list,{name: vals[i][0],desc: vals[i][1]});
}
}