Setting due date based on two conditions
Asked by Pavel:

I have a board with a list named Tuesday. I want to create the following rule. If a card is created in this List, it should be assigned a due date based on these two conditions:

1) If today is Tuesday, then set due date now.

2) If today is Wednesday, Thursday, etc., then set the due date the next Tuesday.

Butler can easily implement condition 2), but how to augment the rule with condition 1)?

Thanks!


Answers:
author: milynnus
body: [@Pavel](/t5/user/viewprofilepage/user-id/3520029)

When you create a new card include a label that has a name using a date variable for day of the week (invisible) and use that to trigger the due dates. It should work.

comments: author: milynnus
body: [@Pavel](/t5/user/viewprofilepage/user-id/3520029)

Card added on Tuesday is due now...it kind to travel to the future and back.

Will wait till tomorrow to add a card because it will have a Wednesday label and next Tuesday due date and will remain "as is" since the second trigger would fail.

![Screen Shot 2021-07-27 at 3.26.14 PM.jpg](https://community.atlassian.com/t5/image/serverpage/image-id/153046i6A8AB85DEDFE30FB/image-size/large?v=v2&px=999 "Screen Shot 2021-07-27 at 3.26.14 PM.jpg")


author: Pavel
body: Hi [@milynnus](/t5/user/viewprofilepage/user-id/3947182) , this is super smart! You guys are amazing! Thanks a lot for your help!


author: milynnus
body: [@Pavel](/t5/user/viewprofilepage/user-id/3520029)

FYI, I tested with a new card created on List "Tuesday" the due date is next Tuesday Aug 3.


author: Iain Dooley
body: [@Pavel](/t5/user/viewprofilepage/user-id/3520029) my first thought was to set the due date to yesterday then move it to the next tuesday, however "the next tuesday" in that command always offsets versus the current time rather than the due date on the card which seems like a bug to me :(

This BenkoBot function would do it though:

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

You can preview the code in your own BenkoBot account by clicking this link and entering your API key/token:

[Click here to preview code in BenkoBot](https://app.benkobot.com/addlistener?functionName=setDueBasedOnListName&code=dmFyIGFkZGVkID0gbmV3IE5vdGlmaWNhdGlvbihub3RpZmljYXRpb24pLmFkZGVkQ2FyZCgpOwoKdHJ5CnsKICBhZGRlZC5zZXREdWUoCiAgICBUcmVsbGluYXRvcgogICAgLm5vdygpCiAgICAuYWRkSG91cnMoMTApCiAgICAubWludXNEYXlzKDEpCiAgICAubmV4dChhZGRlZC5jdXJyZW50TGlzdCgpLm5hbWUoKSkKICAgIC5taW51c0hvdXJzKDEwKQogICk7Cn0KCmNhdGNoKGUpCnsKICAvL1RoZSBsaXN0IG5hbWUgd2FzIG5vdCBhIHZhbGlkIGRheQp9)

Note that BenkoBot currently doesn't support timezones so I've added a 10 hour offset for my own timezone before and after the calculation. I'm in GMT+10, you'd need to modify the add/minus hour amounts to suit your timezone otherwise you might find that the definition of "Tuesday" changes.

Also note this will work for any list named with a weekday, so if you add a card to Wednesday on Wednesday it will set due now, otherwise it will set due to the following Wednesday and so on.

comments: author: Pavel
body: Hi [@Iain Dooley](/t5/user/viewprofilepage/user-id/1416112), thanks for your solution! Super nice idea to move the due date to yesterday first, but unfortunately, as you pointed out, this doesn't solve the problem because of how Butler defines the "next Tuesday". I will try out the BenkoBot functionality, haven't used this tool before, and am excited to try it out!


Tags: butler