Butler: cascade due date update to first attachment only if the new due date is before the existing
Asked by karlcassar:

Hi! Not sure if this has been asked before, or where to look for such information. I would like to setup a main card, which is linked with 2 "sub-cards". For example, let's take an example:

* **Main Card**: Kitchen Remodel
* **Sub Card 1:** Get quote from John
* **Sub Card 2:** Get quote from Paul

I would link Sub-Card1 (two-way) and Sub-Card2 (two-way) to Main Card. Then, I would like to setup some kind of automation to do the following.

* I would like that if Main Card has no due date, and then if I set SubCard1 due date to 15 Nov, this is cascaded as the Due Date for Main Card.
* Then, if I set SubCard2's due date is set to 10 Nov, this re-cascades MainCard's due date to 10 Nov.
* If however, I then update SubCard1's due date to 20 Nov, this is **not** cascaded because it is **after** the existing due date of 10 Nov.

Is a rule like this possible via Butler, or any other automation method?

Regards,

Karl


Answers:
author: Iain Dooley
body: [@karlcassar](/t5/user/viewprofilepage/user-id/2172695) the creation of the sub-tasks is easy with Butler or Trellinator, I wrote about it here:

<https://community.atlassian.com/t5/Trello-articles/Trello-Subtasks-with-Butler/ba-p/1060392>

The cascading due dates won't be possible with the Butler power up (it might have been doable with the Butler Bot which has been phased out ...) but here is a Trellinator function that will do what you need:

<https://gist.github.com/iaindooley/7ba28b44ffe78a845631341a078ddfb6>

This assumes the linking is done in the same fashion above (ie. parent cards linked in attachments, children linked in a checklist).

You can read more about Trellinator here:

<https://community.atlassian.com/t5/Marketplace-Apps-Integrations/Introducing-Trellinator-Automate-Trello-with-Google-Apps-Script/ba-p/925271#U1212977>

comments: author: karlcassar
body: Honestly, this looks very powerful albeit it's a bit overkill for what I need. However its very interesting to know that google scripts can be used for this. I tried to set it up briefly and the tutorial worked. I copied the function, and added it. It seems to be called ok, however then there is an error in log:

```


["Examining Notification: [5dc58c0afce1b08bf30f0b4e-updateCard]","Yes, this is a board level notification...","Processing notification for board: Test Board [5dc587f6124f847952ed72e0]","executing realtime function: setMainCardDateToEarliestSubCardDate","Test Board [5dc587f6124f847952ed72e0]setMainCardDateToEarliestSubCardDate\n54c285f93abd4835b6621b3f967a66d3","function: setMainCardDateToEarliestSubCardDate TypeError: Cannot find function toUTCString in object 2019-11-04T11:00:00.000Z.","Now coming to Global Commands..."]
```

Couldn't determine where is the 'toUTCString'.


author: Iain Dooley
body: [@karlcassar](/t5/user/viewprofilepage/user-id/2172695) oops the setDue command expects a date object, but the due() method of the card returns a UTC string. It's an idiosyncrasy that harks back to the early days of development that I can't easily change in a backwards compatible fashion (ie. ideally I should change it so that the due() method returns a Date object too but there's probably a tonne of stuff that would break as a result :)

And yes using Google Apps Script to automate Trello is incredibly powerful. The early roots of Trellinator are in the work of another Ian (albeit of inferior spelling):

<http://www.littlebluemonkey.com/blog/pimp-your-trello-cards>


author: Iain Dooley
body: [@karlcassar](/t5/user/viewprofilepage/user-id/2172695) note that I've updated the gist with corrected code and tested it out (typically I write the Gist and supply the tutorial but don't test the code unless the person comes back and says "I set up the tutorial but the code didn't work" because most of the time people don't run through the tutorial ;)


author: karlcassar
body: [@Iain Dooley](/t5/user/viewprofilepage/user-id/1416112) Honestly, i'm amazed that you went all that length to submit a code-example for my question, much appreciated. Plus you got me intrigued as it's always good to know there is the possibility of scripting, as it opens up infinite possibilities for automation. I've updated the code, and this works. Thanks a lot! :)


author: Iain Dooley
body: [@karlcassar](/t5/user/viewprofilepage/user-id/2172695) I actually do it quite a bit! You can see tonnes of examples of Trellinator snippets here:

<https://gist.github.com/iaindooley>

I used to create business systems for clients using Butler Bot but I couldn't continue doing that as a consultant so I created Trellinator as a replacement. Later, they retired the bot and the power up was acquired by Trello, and there are many functions that the Bot used to have that are no longer (and apparently will never be) part of the power up so having a way to create custom extensions in a "butler-like" syntax using Google Apps Script is pretty powerful.


Tags: butler