Adding Days to a ticket's due date only on business days

  • 25 July 2022
  • 1 reply

Userlevel 2
Badge +4

Thought i’d share this workflow setup.

Scenario: You want to set up a trigger in a ticket that adds a few days to the due date on changing specific information within the ticket. (days added can even be defined on what was changed and what was changed to) 


Challenge: it is possible that the due date could end up on a weekend outside of business hours as Set Due Date as action overrides business hour settings from my testing. 


Solution: using expressions with the addDays and weekday and if functions, you can specify how many days to add to the due date on a ticket while also avoiding having the ticket’s due date fall on a weekend.



First within the workflow define the condition to that will trigger the addDays expression (example: you have a process step dropdown in the ticket, the condition looks for what step is selected)

Next set up the first expression (E1) that will take the current date/time and add a specified number of days {example: addDays('{{current_date_and_time_iso}}',3) Expected Output: DateTime}

Next set up an expression that get’s the weekday value (E2) for the previous expression {example: weekday('{{E1.result}}') Expected Output: Number}

Next we will check if the Due date falls on a weekend (E3) and if so, modify the due date to fall on monday

{example: if({{E2.result}}==0,addDays("{{E1.result}}",2),if({{E2.result}}==1,addDays("{{E1.result}}",1),"{{E1.result}}")) Expected Output: String}

      -Explaination of above: The logic here checks the weekday value from the due date, if it falls on a Saturday, who’s value is 0, it will add 2 days to the result of the first expression, if it falls on a sunday, it will add 1 day. If neither days apply then the initial result remains the same

Next we have to convert the result of E3 to DateTime (E4) so we can use that to set the due date on the ticket in the workflow

{Example: "{{E27.result}}" Expected Output: DateTime}

Finally create an action to Set Due Date as E4.Result


And there you have it, the due dates can dynamically be set based on conditions within the ticket all the while keeping the due dates within the work week. Hope this helps! 



1 reply

Userlevel 2
Badge +4

Correction above:

Incorrect {Example: "{{E27.result}}" Expected Output: DateTime}

Correct: {Example: "{{E3.result}}" Expected Output: DateTime}