Using Custom Field as date increment in Butler card button
Asked by Rudy Ramsey:

I want to set up a card button that can, among other things, add an increment to the current due date of the card, where different cards have different increments. Common increment values for me would likely be 1, 2, 7, and 30. Hopefully you get the idea.

I expected to be able to use a custom field {{%Date Increment}}, where the Custom Field pop-up would nicely display the increment for me, so I wouldn't accidentally apply it to a card which doesn't have the "Date Increment" variable set. Based on and example in the Trello help on "variables":

`when a card is moved to list "Done" by anyone, add member @{{%Tester}} to the card, and post comment "@card Task with priority {{%Priority}} was completed and is ready for testing.",`

I expected to be able to say "move the due date by {{%Date Increment}} days", but that doesn't work. Is this another example of Trello catching up with Butler, or is the Custom Field pop-up not as integrated as I understood from the help text, or have I just done it wrong?


Answers:
author: Pieter van Diggele
body: I was looking for a similar solution and I found a way to calculate a card's due date based on custom field value's, based upon a combination of [custom field arithmetic](https://help.trello.com/article/1160-custom-field-variables#custom-field-variables) and [arithmetic in date variables](https://help.trello.com/article/1159-arithmetic-in-date-variables) and the [lookup function](https://help.trello.com/article/1193-butler-card-lookups) to retrieve a value from another card.

I use two custom fields in my cards:

* Due (date field) - to manipulate the due date, which can later be retrieved to set the card's due date
* Extime (number field) - to store the number of weeks I need to move the original due date by

To know by which amount of weeks I need to move the due date, I first retrieve that value from a config card in a config list I've setup on the board.

*lookup a card titled "{cardname}" in list "Config", set custom field "Extime" to "{foundcarddescription}"*

Then I recalculate the Due field by subtracting x weeks from the original date.

*set custom field "Due" to "{{%Due}-{{%Extime}}w}"*

The last step is to set the card's due date to the same value as the Due custom field.

*and set due date on the date in custom field "Due"*

It took me quite a while to figure out this solution, so I hope this will save anyone looking for a similar solution some precious time! ?

comments: author: Rudy Ramsey
body: This exact solution wouldn't be workable for me because of the need to maintain the Config card. I would want either me or my non-programmer assistant to be able to set up a cycling card at will. But your solution might well point in the right direction.

I haven't looked at this level of Trello programming for a while, but I wonder if you could adapt this so it's driven by a label on the card itself, rather than by a lookup in a common card. So, for example, if the card has label "Cycle 14", that information is used to feed 14 days into your computational algorithm. There would be a small, fixed set of such labels, and their mapping \*could\* use a Config card, if that allows a particular label text to be mapped onto a particular numeric value. I just wouldn't want to have to go and add an entry to the Config card for each individual card that's making use of the technique.

IAC, thanks for letting us all know about this approach.

Rudy


author: Iain Dooley
body: [@Rudy Ramsey](/t5/user/viewprofilepage/user-id/3375616) You could do this by adding multiple commands that filter based on label, ie.

*when a card with label "7 days" is moved to list "Whatever" move due date by 7 days*

You'll be able to see which cards have which increment by the label. You'll need the paid version in order to create multiple versions

comments: author: Rudy Ramsey
body: Thanks, Iain. That does work well, though I begrudge it the rules clutter and label clutter (so far, I have six of each, and may need to handle more intervals in the future on my 14 boards). Still, it allows a single-op solution to a complex series of actions, and I've implemented it. Thanks for the suggestion.

I'm not going to "Accept" this answer at the moment, though, as I would really like to understand what prevented the Custom Field solution. That's less about this specific need, which you've addressed tolerably well, than about understanding how to use Custom Fields in general, as this certainly isn't their only use.


author: Stacie Shaw
body: Rudy, did you ever find an acceptable resolution to this?

I am facing the exact same challenge. While I see that the label-as-a-trigger Iain suggested may help in some circumstances, especially when there is a finite number of options (like 1, 2, 7), it's not very clean for the way I am intending to use this. It seemed that was your reaction as well.

The "move the due date by {{%Date Increment}} days" is exactly what I need too. Better yet if I can do math with custom fields (like {{%field1} - {%field2}}) But I'm not greedy, I'd settle for a simple "move the due date by {{%Date Increment}} days"

It seems as though this would be feasible. Any solution or workaround that you found?

comments: author: Rudy Ramsey
body: Hi, Stacie.

I did wind up using a variant of Ian's solution, and it works OK for my situation. It still clutters my labels and rules, but function is more important that appearance, and maybe more important than convenience, I guess. I've devoted a color to labels that are about repeating tasks with various intervals. The labels are "Cycle 1", "Cycle 2", "Cycle 3", "Cycle 7", "Cycle 14", "Cycle 28", and "Cycle Mo". (Are you starting to see where the clutter comes from?) I also have just "Cycle", for other intervals, irregular ones, or intervals I can't express quite so easily. This type I have to advance manually.

Then I have a label (different color, which I use for some other action commands, as well), which says "+Cycle". This triggers a rule (separate for each of the intervals) that does the advancing. It does a number of other things, as well, removing Member assignments, removing an "In Work" flag, and removing a connected card on my Dashboard board, but those things have nothing to do with your question.

Clunky and inelegant, but it works. :)

Rudy