Dynamics 365 – Closing an Incident/Case Automatically Based on Status and Time Waiting

Today I’ll be demonstrating a simple method to close a case automatically if it remains in a specified Status for a certain length of time. This is particularly useful if you want to close cases if, for example, they haven’t had a reply from a customer within two weeks or similar.

To do this you will require the permissions to create workflows and fields on the case entity.

The Solution

Create the Required Field on Case

  1. First, we need to create a field called ‘Time Waiting’ which should have the same settings defined in the image below. This field will contain the date that we want to close the case if it’s not been updated.closeCaseOnWaiting
  2. Once done, Save and Publish the new field.


Create the Time Waiting Check Workflow

  1. Go to Processes and create a new Child Process Workflow on the Case entity. This workflow will just calculate whether the ‘Time Waiting’ fields date/time is lower than or equal to the current Execution Time.closeCaseOnWaiting2
    • Ensure that ‘As a child process’ is checked as we’ll run this from a different workflow.
    • In order to get the ‘Case:Time Waiting <= [Process-Execution Time]’ check simply click the criteria and select Case – Time Waiting – Is Less Than or Equal To and then in the final field change the ‘Look for’ drop-down to ‘Process’ and then select ‘Execution Time’
  2. Save and Activate the process so that it will be available from our next workflow.


Create the Trigger Workflow

  1. Create a new workflow, again on the Case Entity.
  2. In the ‘Start When’ options check ‘Record fields change’ and then select the ‘Status Reason’ field. This is because we want to trigger the workflow when we’ve set the case to a specific Status Reason.
  3. Add a ‘Check Condition’ to the workflow logic and set it up as in the following image (you will likely want to change the Status Reason to suit your needs)closeCaseOnWaiting3
  4. In the workflow, select the If condition you just created and then click ‘Add Step’ and add a ‘Conditional Branch’.
  5. Set up the condition to be the same as the image below. This conditional branch will contain the logic to reset the Time Waiting field or to clear it entirely depending on the status.closeCaseOnWaiting4
  6. In this conditional branch add an ‘Update Record’ step and set it to the Case entity.
  7. Click ‘Set Properties’ and find your ‘Time Waiting’ field in the form, click it and set the Operator to ‘Clear’ so that it will remove the value if a change is detected.
  8. Save and close this step.
  9. In the first if statement you now need to add an ‘Update Record’ Step on the Case entity.
  10. Click ‘Set Properties’, locate the ‘Time Waiting’ field again and set it ahead by however much time you want to wait before closing a case minus 5 minutes or so. For example, if you want to wait 14 days then set it to 13 days, 23 hours and 55 minutes as in the image below. This is because we’ll compare whether this date has passed in order to close the case automatically.closeCaseOnWaiting5
  11. After this step and within the same if statement add a ‘Wait Condition’.
  12. Set the condition to Process – Timeout – Equals and change the operator on the right to Duration and set it to the time you’ve chosen to wait. In my case, I’ve set it to 14 days. If you have done this correctly it should show as ‘Timeout until *time* then’ in the workflow window.closeCaseOnWaiting6
  13. Within the timeout add a ‘Start Child Workflow’ step and set it to the Case entity.
  14. Do a lookup and link the action to the workflow you created earlier.
  15. If you’ve followed these instructions you should end up with a workflow similar to the image below.closeCaseOnWaiting7.PNG
  16. Activate the workflow.


From now on whenever a case is set to ‘Awaiting Customer’ in my case, the larger workflow will trigger and set the Time Waiting field to the Execution Time plus the timeout period you set which provides a sort of counter. The workflow will then wait for the duration of the timeout period and will run a workflow which will see if ‘Time Waiting’ has passed.

At any point, if the case is set to any other status then the ‘Time Waiting’ field will be cleared meaning once the workflow finishes it will not close the case.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.