Currently, I came across a scenario where we had to configure a workflow to send an e-mail on a specified date value on an opportunity entity. On opportunity entity I had a date field “Date 1” and what we were required to do was to send an email to opportunity owner on a date specified in the Date 1 field value. To achieve this, I can configure a workflow with timeout or wait condition set on the Date 1 value.
First, I tried to make it work using the Timeout criteria but it seemed to fail our requirements when the date value is null. So, I decided to work with wait condition.
Following are the steps configured in workflow to meet the requirements:-
Step 1: Start workflow on Record Created and Record Fields change. In Record fields change select the Date1 field.
Step 2: Check if Date1 field is null. If the field is null then no need to set any wait condition.
Step 3: Since we have fired this workflow on field change also, we had to make sure that there should not be more than one workflow with wait condition. When opportunity record is created and Date 1 field contains data, a workflow record would be created in wait mode. At the same time, if somebody modifies the date 1 value for the same opportunity record then another workflow record should not be crated in waiting mode to be executed on that particular updated date value. Instead, the previously created workflow should be updated with new value. To achieve this we have taken a custom attribute here DateValue which is a two option field. Default value of DateValue is false. Once a date is entered the value of datevalue gets updated to true. This way we ensure that on field change we don’t create a new wait condition if one already exists.
Step 4: If the attribute value is false means there is no previously existing system job with wait condition. So, Add step of wait condition and set process execution time on or after the Date1 value. If the value is true means the workflow record was already created and nothing to do in that scenario.
Step 5: Add a Send Email step and configure required values.
I hope this would be helpful.