When we come across adding any kind of wait conditions in our workflows, we only think of Wait and not Timeouts. We need to be careful when choosing either one of them.

They both seen to be the same, but they do serve different purpose. Depending on the requirements, one of them can perform better and accurately as per what we need.

Wait is more dependent on a value in a field which is not of a type date or time. Wait postpones a workflow until a condition changes depending on a value in a field. For example Wait until the "Approval" field is set to "Yes" by the manager. On the other hand Timeout is more dependent on date and time. Timeout postpones a workflow until a date/time condition relative to a value in a specified CRM record's date/time field.

1) Timeout:

Timeout is more date and time related.

For example, there is an entity called Movies. Every time an admin user adds a new movie record, an email needs to go out to a Manager. The email will request the Manager to validate the data and approve the movie record. This email will be sent after 2 days of the record being created. In these 2 days the admin user can edit the movie data as many times as required. After the manager approves the record, there is a radio button field called "Approved" which will be set to "Yes".

Step 1:

I will create a workflow for this timeout scenario. I have opened my unmanaged solution called Movies. I will go to my Processes section and click on New to create a workflow.

Add a New Workflow
Add a New Workflow

Step 2:

I have entered all required fields for my workflow. I will call my workflow "Approve a new Movie". The workflow will timeout, until 2 days after it has been created. Exactly after 2 days, it will send an email to the Manager for approval.

New Workflow Details
New Workflow Details

Step 3:

This workflow starts on an event when a Record is created. Inside the workflow UI designer, I will add a new Step. The step is a Wait Condition.

Note: The step for Timeout is within the Wait Condition but we can specify it as a Timeout condition. Timeout is a kind of Wait, and the workflow is in sleep mode till a particular date/time condition is met.

Add a New Step
Add a New Step

Step 4:

The Wait Condition step is added. I will name it "Approve the Movie". I will now "click to configure". This will bring "Specify Condition" window.

Edit Condition
Edit Condition

Step 5:

I will add a condition. I will select a condition of Timeout till Process is over 2 Days after the record is created. The condition of "2 days after Created On" is selected on the right hand side under Dynamics Values. Click "Save and Close" button.

Timeout Condition
Timeout Condition

Step 6:

Now we have a Timeout condition. I will add a step of emailing the manager if the Timeout condition is met.

Timeout Condition Created
Timeout Condition Created

Step 7:

Add a step to send an email. I will name this step as "Email Manager".

Step of Emailing Manager
Step of Emailing Manager

So what I have done above is to have the workflow timeout until 2 days after a new Movie record has been created. As soon as a new Movie record is created, a new instance of this workflow will be created and immediately go in sleep mode or timeout mode. The workflow will do nothing till the 2 days have passed. These 2 days are taken from the Created On date and time. After 2 days, the workflow will execute the next step of sending an email to the manager.

Step 8:

Now let's take the same scenario and have a Wait condition instead of a Timeout condition. I have modified my workflow to look like below.

Wait instead of Timeout
Wait instead of Timeout

The above condition states the workflow to wait until Created On is less than 2 days after the movie record has been created. This Wait condition looks a bit odd as compared to the usual looking Timeout condition. This is because Wait is more for non-date and non-time conditions based on a value of a field. If we run the above Wait workflow, it might not run exactly 2 days after. The workflow may run after 1 hour of the condition being met. So in our date and time scenario Timeout works best.

2) Wait:

Now let's take a second scenario. We need to email the record owner of the Movie as soon as the manager approves this record. This could have been handled by a simple workflow which runs after the status of the Approved field changes to Yes. When a manager approves and saves a record, this workflow will fire. For my demo purpose, I will modify the logic a bit and introduce a Wait condition.

Step 1:

The workflow which I am creating below will execute whenever a new Movie record is being created. After an instance of workflow is created, it will go in a Wait condition. This Wait condition will postpone the workflow till the Manager approves this record. Below is a new workflow.

New Workflow for Wait Condition
New Workflow for Wait Condition

Step 2:

This workflow will start when a Movie record is created. Inside the workflow UI designer, I will add a new Step. The step is a Wait Condition.

Add a New Wait Step
Add a New Wait Step

Step 3:

I will now "click to configure". This will bring "Specify Condition" window.

Edit Wait Condition
Edit Wait Condition

Step 4:

Here I create and add my Wait condition. The condition is to Wait until Approved field is Equal to Yes. Click "Save and Close" button.

Wait Condition
Wait Condition

Step 5:

This will create the Wait condition. I will name it "Wait till the Movie Record is Approved".

Wait Condition Created
Wait Condition Created

Step 6:

I will add a step of emailing the owner of this movie record. I will name this step as "Email the Record Owner".

Email the Record Owner
Email the Record Owner

We finish creating the workflow for the Wait condition.

For a new movie record, a new workflow instance gets created and goes into Wait state. Whenever manager approves and saves the record, immediately the workflow will come out of sleep mode. Workflow will check whether the record is approved. If "Yes", then email the record owner informing of the approval. In this scenario the Wait condition is more suitable than timeout, as the field value is non-date and non-time.

I hope this blog about 'Microsoft Dynamics CRM 2011 - Workflows Wait and Timeout' was informative. Please feel free to leave your comments.