Skip to main content

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:

  1. 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.

  2. If the deadline falls outside of this range, it should be set to the calculated date (3 weeks from the completed task).

  3. 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!

The Scheduled workflow only run non-completed tasks. 
Same as they only run on non-closed tickets. 

 


So in your case you need to use a custom date field on the ticket assuming it’s not closed also then it’s not going to work at all. 

When the first task is completed it sets the custom date field. 

Then you need to use a Scheduled ticket workflow with the expression 

Something like this, it’s a start I haven’t tested it, can  do that later 
You could skip the whole check for weekend and do it another expression 

if(day('{{ticket.due_by_time_iso}}') >= 0 && day('{{ticket.due_by_time_iso}}') <= 14,
date(year('{{ticket.due_by_time_iso}}'),month('{{ticket.due_by_time_iso}}'),15),
addDays('{{ticket.due_by_time_iso}}',21)
)



if(weekday({{E1.resault}}) == 1,
addDays('{{E1.resault}}',1),
if(weekday({{E1.resault}}) == 7,
addDays('{{E1.resault}}',2),
{{E1.resault}}
)
)
)




 


Hi Daniel,

Thanks a lot for your detailed explanation and for sharing your expression – it was really helpful and a great starting point.

I was able to test the expression in the Expression Tester, and it returned a valid result (e.g. 2025-06-05), so the logic itself seems solid. However, when applying it in a real workflow to set a custom date field (e.g. task_due_date_calc), the field ends up being set to None.

Here’s what we tried:

  • Used the expression to calculate a date 3 weeks after task completion, adjusted to the 15th if the result falls between the 1st and 14th.

  • Added logic to shift the result to the following Monday if it lands on a weekend.

  • Verified that the expression works via “Test Expression” – it returns a proper ISO date string as expected.

  • Used an action to “Set custom_field.task_due_date_calc as E1.Result” – this executed in the workflow but still resulted in None being saved in the field.

  • Even tried breaking up the logic into separate steps (e.g. calculate base date first, then handle weekend logic in another step).

Despite all that, Freshservice seems to ignore the expression result when saving it into a custom date field. We suspect the system either:

  • Fails to parse complex or nested expressions correctly at runtime, even if “Test Expression” passes.

  • Or perhaps only allows simple values or literal dates to be written to date fields.

Because of these limitations, it seems too fragile to build a scalable workflow (especially for many tasks) relying on expressions alone.

Thanks again for your help – your suggestion really helped us get as far as we could. Hopefully Freshservice will improve expression support for dates in the future!

Best regards,

 Anders


Check the execution logs and post them. 

If a date field is empty you need to “set” it before. You can do it with a expression as well, something like this.

 

if('{{date_field_iso}}' == '',date(2025,05,05),{{date_field_iso}})

Can replace the date() with the placeholder for system date or another date placeholder. 


Hi again,

Thanks for response! I will try that. It’s however still to complicated to use in real life in my opion. The “feature” is requested for like 20 tasks in different variations, and that’s just to many custom fields and workflows to be practical, especially for the super users I had hoped could take care of this. 

 

/Anders


Reply