Skip to main content

Notifications

Microsoft Dynamics AX forum

Due date/time calculation in workflow

Posted on by 290,782 Super User 2024 Season 2

Hi all,

Within a certain workflow we are looking for a way to fulfill escalation at certain fixed due dates. Suppose every Monday at 16:00 a certain task should be due. This is related to the process of the customer where there are some deadlines defined in the process where workflow is also used. This is currently not possible as you can only specify hours or days in addition to the start time of submitting the workflow.

The date/time due is also depending on the contents of the document. Take for example a timesheet. If the timesheet is submitted with a period in future (worker writes future absence hours) also the due date is probably a week later than the first coming Monday. If a timesheet is submitted too late (e.g. after 16:00 at Monday for the past week, the due date needs to be the current date/time)

As mentioned this is not possible by default. Has anyone had this similar requirement or has a solution (direction) available? Possibly we need to create a customization so only an answer you can customize it is not the answer I'm looking for. I wonder if anyone can share his experience or also support me in just telling that you have the same requirement.

*This post is locked for comments

  • Suggested answer
    Jonathan  Halland Profile Picture
    Jonathan Halland 11,304 on at
    RE: Due date/time calculation in workflow

    Hi Andre.

    You can checkout the post over here: www.exploreax.com/.../creating-a-custom-workflow-due-date-provider

    Please let me know if you see errors or have suggestions on how to improve it.

  • André Arnaud de Calavon Profile Picture
    André Arnaud de Cal... 290,782 Super User 2024 Season 2 on at
    RE: Due date/time calculation in workflow

    Hi Sohaib, Jonathan,

    Thanks for your answers. Both suggestions were on my list. Creating the table with setup and a batch is a solution which for sure will work, but not the preferred one.

    So we were about looking into the details of the due date providers. I think the directions from Jonathan are very helpful. Tomorrow we are going to have some detailed look into these classes and will try to find out if we can achieve the requirement.

    An extensive blog is still welcome :)

  • Verified answer
    Jonathan  Halland Profile Picture
    Jonathan Halland 11,304 on at
    RE: Due date/time calculation in workflow

    Although I haven't done it myself, you can use the "WorkflowWorkCalendarDueDateProvider" as an example. Basically in the resolve methods you can get the original record out of the "WorkflowContext" object and resolve it to a fixed date in anyway you choose.

    Basic steps

    1. Create class extending WorkflowDueDateProvider

    2. Create getCalendarTokens method and return a key value for each resolution type you would like. Probably only 1. e.g. Monday 16:00

    3. Create resolve and resolveNonUser methods that retrieve the original document via _context.parmTableId() and _context.parmRecId() and returns a date of your choosing.

    I hope this helps a bit. I'd be happy to create a more extensive blog post or something if needed.

  • Jonathan  Halland Profile Picture
    Jonathan Halland 11,304 on at
    RE: Due date/time calculation in workflow

    Hi Andre.

    Have you looked at creating a custom DueDateProvider in workflow?

  • Verified answer
    Sohaib Cheema Profile Picture
    Sohaib Cheema 46,610 User Group Leader on at
    RE: Due date/time calculation in workflow

    Have to thought to do it as following:

    1. Created a new setup table/form, where I do define that when a workflowTypw will be due (every Monday at 16:00)
    2. Create a new Batch/class which will run and make the task/workflow due as per specifies time in setup(#1). This batch job will make the task/workflow due, by code

  • André Arnaud de Calavon Profile Picture
    André Arnaud de Cal... 290,782 Super User 2024 Season 2 on at
    RE: Due date/time calculation in workflow

    I tried to play with available days to have e.g. only the Monday as working day. This is also not giving the correct results.

    In the Time limit settings of the workflow you can specify a Duration. If possible we would like to add an option here. Does anyone know if this part is customizable? In the meantime we will investigate further.

    Another option could be creating additional tasks which loops through the pending workflows and set the due date/time afterwards.

    If anyone like to respond on this thread, you are welcome to share your thoughts.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum Structure Changes Coming on 11/8!

In our never-ending quest to help the Dynamics 365 Community members get answers faster …

Dynamics 365 Community Platform update – Oct 28

Welcome to the next edition of the Community Platform Update. This is a status …

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 290,782 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 229,067 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,150

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans