Skip to main content

How to config timer by number of working days? E.g. trigger a reminder e-mail after 5 working days

info

Starting with WFE 11.0 you can use work calendars for this task

In order to customize the timer, you should create a handler for GetCustomTimerValueAsync:

runtime = new WorkflowRuntime();
runtime.GetCustomTimerValueAsync += GetCustomTimerValueAsync;
...
runtime.Start();

This handler is called when registering the timer with TimerType = Expression, and the Value string that differs from the format: "2d 5h 24m 15s", "2days 5hours", etc.

Thus, by implementing the handler, you can send and process any values necessary to implement an algorithm of your own.

Example of using the handler:

class TimerValue
{
public int WorkingDays { get; set; }
}

public static async Task<DateTime?> GetCustomTimerValueAsync(string value, string name)
{
TimerValue timerValue = null;
try {
timerValue = JsonConvert.DeserializeObject<TimerValue>(value);
}
catch { }

if (timerValue != null)
{
// TODO: Add your algorithm for calculating working days.
return runtime.RuntimeDateTimeNow.AddDays(timerValue.WorkingDays);
}

return null;
}

In the designer, creation of a new custom timer will look as follows:

Workflow Timer Value