Whenever user sets due date on task record, a reminder should go to owner of the task.
Implementation Approach: We will implement this using a workflow with below configuration:
- Create a background workflow on task entity.
- Set trigger points of workflow as below:
- When record is created.
- When task due date is updated.
- Set workflow logic as below:
- Wait until Due Date becomes true (i.e. wait until due date arrives).
- On success, send email notification.
Note: In this blog, I have not focused on how workflow is created and how above steps are achieved.
Above approach will not work properly in below scenario:
- User creates task and sets due date as 5 days later.
- A background process will be created and will go in wait condition.
- User again opens the task created above and updates the due date as 7 days later.
- In this case as well, new background process will be created and will go in wait condition.
Now, when actual due date arrives i.e. 7 days after, both of the background processes will be succeeded and 2 email notifications will be sent to the owner. This is incorrect and needs to be fixed.
To solve this issue, I have created a custom workflow assembly which checks active background process count associated with the record and returns the value back in output parameter. So, if we call this custom workflow as a first step in our workflow and if active session count is equals to 0, then we can proceed else we will stop workflow.
This way, at any given point of time, there will be only 1 active session which will be succeeded on actual wait condition success.
I have attached managed solution which contains below 2 components:
- Custom Workflow Assembly.
- A sample workflow on task entity (in deactivated state) to show an example and how to use it.
Download managed solution here.
How it works