SBX - Search With Button

SBX - Forum Post Title

Due date/time calculation in workflow

Microsoft Dynamics AX Forum

Question Status

Verified

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.

Reply

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.

Reply
Sohaib Cheema responded on 9 Apr 2015 1:15 AM
My Badges
Verified Answer

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

Reply
Jonathan Halland responded on 9 Apr 2015 1:36 AM
My Badges

Hi Andre.

Have you looked at creating a custom DueDateProvider in workflow?

Reply
Jonathan Halland responded on 9 Apr 2015 1:55 AM
My Badges
Verified Answer

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.

Reply

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 :)

Reply
Jonathan Halland responded on 9 Apr 2015 8:56 AM
My Badges
Suggested Answer

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.

Reply
Sohaib Cheema responded on 9 Apr 2015 1:15 AM
My Badges
Verified Answer

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

Reply
Jonathan Halland responded on 9 Apr 2015 1:55 AM
My Badges
Verified Answer

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.

Reply
Jonathan Halland responded on 9 Apr 2015 8:56 AM
My Badges
Suggested Answer

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.

Reply

SBX - Two Col Forum

SBX - Migrated JS