Hello,
I’m trying to set up a workflow automation in Freshservice where a new task is created 3 weeks after a task is marked as "Completed", but I need to ensure the following conditions for the due date of the new task:
-
If the 3-week deadline falls between the 1st and 14th of the month, the due date should be set to the 15th of the month.
-
If the deadline falls outside of this range, it should be set to the calculated date (3 weeks from the completed task).
-
Additionally, if the calculated date happens to fall on a weekend (Saturday or Sunday), I’d like it to be adjusted to the following Monday.
I’ve tried using the Expression Builder with functions like addDays()
, formatDateTime()
, and if()
, but I keep encountering syntax errors or incorrect results.
Here is the expression I’ve tried so far:
if( formatDateTime(addDays(task.completed_at, 21), "dd") <= "14", parseDateTime(formatDateTime(addDays(task.completed_at, 21), "yyyy-MM") + "-15"), addDays(task.completed_at, 21) )
This doesn’t seem to work as expected, and I’m getting syntax errors or incorrect results.
Can anyone help me with the correct expression or guide me on how to set this up?
Thanks in advance for your help!