hello everyone,
I am trying to create an automation that creates every 1st of the month, sub-tasks of all Wednesdays (for example) of the month where the field ""recurrent re-opening[Dropdown]" = Weekly" is selected.
This creation must depend on a variable date field called "Final Solution Date." (If for example a Monday is entered, the next month must create the sub.tasks of all the Mondays of that month etc.).
Now my problem, by putting in the "final solution date" of my main task on April 12 (which is a Friday for example), I would like it to create on the first day of the next month the sub-tasks of the remaining Fridays, and thus: the 12th, the 19th and the 26th (total 3 sub-tasks).
If I then change the date and put May 1, it should create 5 of them (being 5 Wednesdays in that month).
How can this be done?
Thanks
Hello @Mattia Battan
I am not understanding the trigger of your requirement..
I gather that based on what "Final Solution date" is entered, you want to create sub-tasks, but What if this field is changed again same month? Wont you end up with multiple sub-tasks everytime? So your requirement is confusing.
But assuming this field change is the trigger and it will be changed only once..
Probably many ways to do this, I guess I am proposing a brute force check.. Looking forward to other options as well...
My suggestion:
Below smart values gives you number of wednesdays in a month:
{{#=}}CEILING({{Final Solution date.firstOfTheMonth(3).diff(Final Solution date.lastOfTheMonth(3)).days}}/7 + 1){{/}}
Where,
Again, assuming your trigger is field change to "Final Solution date" field. You can do a refetch action after the trigger and then do the If/Else condition check and create sub-tasks accordingly.
Now, We know a month can only have either 4 or 5 wednesdays, So before you start creating sub-tasks, put an if/else condition -> smart value condition and check if above smart value equals 4, if so create 4 sub-tasks, else create 5.
Like below screenshot: (Its a DC screenshot but cloud has similar logic)
To test this.. what ever your trigger, use your field, Final Solution date and below smart value for checks:
{{#=}}CEILING({{issue.Final Solution date.firstOfTheMonth(3).diff(issue.Final Solution date.lastOfTheMonth(3)).days}}/7 + 1){{/}}
But dont create sub-tasks yet, just log like I did to make sure you are entering the correct If condition.. Only after verifying that, I suggest you create sub-tasks to avoid unnecessary issues.
hi Kalyan,
my trigger starts once a month, on the first of the month and reads the "final solution date" of the main task, and having set for example April 3, I would like only 4 subtasks to be created with the final solution dates:
- April 3
- April 10
- April 17
- April 24
Leaving April 3 as the main task, I would like 5 subtasks to be created on May 1:
- May 1
- May 8
- May 15
- May 22
- May 29
On the other hand, if at any time the "final solution date" of the main task is changed, from the next first of the month, it will have to create the number of subtasks in relation to that day.
I think the only thing I am missing is to add an "if" that does this check.
Thanks
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Kalyan Sattaluri I tried your rule and it works when the Wednesday of the month selected in the "final solution date" has 4 or 5 weeks.
How can I make it variable, i.e. your "if" doesn't read only if Wednesday has 4 or 5 weeks, but any day?
thanks again
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello @Mattia Battan
Hmm. I am not sure what do you mean by "variable"? Where will this variable come from? user input? or derived from the date in your field? I personally think you are complicating this. I honestly dont know how to do that without extensive If/Else statements... There maybe simpler approach I am missing.
My suggestion is to please take a moment to understand/document what do you want / requirement.
Then please post a new question / thread so community can help.
In the mean time, if the original ask of this post is clarified, please consider accepting the answer so others can benefit. Thanks!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hi @Kalyan Sattaluri ,
I confirm that your formula works, I actually had to add some "if", also I had to create 4 separate automations (there is a limit of 65 steps per single automation). For example if the month has 4 days and the "final solution date" was a Monday I did as in the screenshot, then there is an "if" for each day of the week.
Thanks
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Can you clarify the logic for us here?
...is this correct?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hello Stephen,
Let me explain further:
- The manager of our finance department has main tasks and must have a number of precise sub-tasks regarding the current month
- every 1st of the month automation is triggered, which reads the "Final Solution date" field (which can change from month to month) and creates sub-tasks
- for example setting May 1 (a Wednesday), it should create 5 subtasks (because May has 5 Wednesdays)
- however, if he sets June 5 (a Wednesday), he should create 4, because there are 4 Wednesdays in June.
So it should be from month to month variable based on the change of the "Final Solution Date" of the main task.
At the moment I made a rule that creates 5 sub-tasks regardless, but this doesn't work for me, because for example with May it worked correctly, but with April it didn't (it created an extra sub-task with "final solution date" May 3 and this was supposed to be created the next month:
Thanks
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.