Skip to content

Instantly share code, notes, and snippets.

@iaindooley
iaindooley / gist:3b5bd2fdd8f327fa8fe750e82bd6d587
Created Apr 22, 2019
Set Custom Field Values From Due Date
View gist:3b5bd2fdd8f327fa8fe750e82bd6d587
function setCustomFieldValuesFromDueDate(notification)
{
//Will trigger for adding or editing a due date
var card = new Notification(notification).addedDueDate();
//Set these offsets accordingly. The element name is the
//name of the field (eg. production stage) and the value
//is offset in days, plus or minus
var offsets = {"Field 1": -1,
"Field 2": -3,
"Field 3": -7};
View gist:997924efc2e2166cef1e33a122305f1a
function debug()
{
//Contents of the "Function Call" column in ExecutionQueue
var obj = {"functionName":"scheduleFirstSendCards","parameters":{"id":"5a39fd61285a2899ed212e7a"}};
//This will simulate exactly the function call with the added benefit that you can run it
//directly from the script editor, and that you can then use the built in Google Apps Script
//Logger.log() to write logs which you can view in the script editor which can be quicker than using
//Trellinator.log and having to view them in JSON format
scheduleFirstSendCards(obj.parameters);
}
View gist:d43df0db37142c72f0850f4e2101b77f
function setNewCardId(notification)
{
new Notification(notification)
.createdCard()
.setCustomFieldValue("Unique ID",latestCardId());
}
function latestCardId()
{
var card = Card.findOrCreate(Board.findOrCreate("System Configuration").findOrCreateList("Card ID"),"Latest Card Count");
@iaindooley
iaindooley / gist:8c69a0822c048bd5d062de510341ded2
Created Apr 19, 2019
Search based on custom fields within board
View gist:8c69a0822c048bd5d062de510341ded2
function searchBasedOnCustomFieldsWithinBoard(notification)
{
var field = new Notification(notification).changedCustomField("Query");
field.card().board().cards().each(function(card)
{
if(card.id() != field.card().id())
{
field.card().board().customFields().each(function(loop)
{
@iaindooley
iaindooley / gist:dba84f2792fba2ee97dd8bbb2b916dc5
Created Apr 19, 2019
Search all boards and cards by custom field
View gist:dba84f2792fba2ee97dd8bbb2b916dc5
function searchAllBoardsAndCardsByCustomField(notification)
{
var field = new Notification(notification).changedCustomField("Query");
new Trellinator().boards().each(function(board)
{
ExecutionQueue.push("findMatchingCustomFieldCards",
{card_id: field.card().id(),board_id: board.id(),field_value: field.value()},
"findMatchingCustomFieldCards-from-searchAllBoardsAndCardsByCustomField-"+board.id(),
Trellinator.now());
View gist:1868e392b9dfb3d1ab7544617c45ca03
function searchBasedOnCustomFields(notification)
{
var field = new Notification(notification).changedCustomField("Query");
new Trellinator().boards().each(function(board)
{
board.cards().each(function(card)
{
if(card.id() != field.card().id())
{
View gist:6f770088101f269bc33f35c97aea73ce
function notifyWithAttachments(notification)
{
var card = new Notification(notification).addedCard("Internal review");
try
{
card.postComment("@board ready for review. Here are the attachments\n\n"+card.attachments().find(function(att)
{
return att.link();
}).asArray().join("\n"));
View gist:ea6dc43e9b5b16fc4907a31338be209a
//INSTALLED ON YOUR JOB OVERVIEW BOARD, ONE CARD PER JOB
function linkToJobBoardBasedOnLabel(notification)
{
var label = new Notification(notification).addedLabel();
//CREATE A NEW BOARD FROM Label Name Template AND ATTACH A LINK
//TO THE CREATED BOARD, ONTO THE JOB CARD
//ADD THE BOARD TO THE "Job Boards" GLOBAL COMMAND GROUP
label
.card()
.attachLink(Trellinator.addBoardToGlobalCommandGroup(new Trellinator().board(label.name()+" Template")
View gist:0d8ac2b64df7aa0fe65cca004aa4b804
function setCreatedInListName(notification)
{
var card = new Notification(notification).createdCard();
card.setCustomFieldValue("Created In Lisrt",card.currentList().name());
}
@iaindooley
iaindooley / Full audit trail
Last active Apr 19, 2019
Full audit trail
View Full audit trail
function fullAuditTrail(notification)
{
var notif = new Notification(notification);
var card = notif.card();
try
{
var sheet = SpreadsheetApp.openByUrl(card.attachment("Full Audit Trail").link()).getSheetByName("Actions Log");
}
You can’t perform that action at this time.