2 Prevent Duplicate Workflows Shared by Derek Mangrum, Central Christian Church (AZ) 28 days ago 7.0 General Intermediate We have some workflows that seem to breed active instances... like rabbits! These workflows tend to start with a User Entry Form somewhere early on and then hang around while some lengthy process is taking place. Let me paint a picture.A person starts a workflow with a User Entry Form for some process. Perhaps they were sent to the workflow via a link in an email. The person visits the link, starting a workflow instance. They may fill out the form... may not. Then, at some point later, they click the link in the email again to start/complete the process. In their mind, they think they are going to the 'same form' each time. In reality, a new workflow instance is being created with each visit. So, you look at your workflow instances list and see five copies for the person... two of which have form data and have gone on to alert someone on staff that other work needs to be done, causing frustration for everyone.We use this Recipe to help limit/eliminate this problem. The basics of this recipe are:Have the workflow check to see if there is already an existing workflow for this person.If so, redirect the person to that existing instance, and then delete yourself.If not, record that you are the current existing workflow for this person and then proceed.Delete your 'workflow instance' record so this person can use this workflow again in the future.The tool we use for this is the User Preference. It is a great place to store a key-value pair for this quick check.We implement it like this:Persist Workflow (Immediately). This makes sure that you have a WorkflowId on record for reference.Get Active Workflow ID UserPreference. This uses a Workflow Attribute we name 'Active Workflow Id' to store the result. It also uses a Workflow Attribute of 'UserPreferenceKey' to store the UserPreference Key value. This Key value can be anything you want. I would recommend naming it in such a way as to minimize the possibility for collisions with other values.From here, the 'Active Workflow Id' attribute will either be blank or have a value in it. You can then use this in RunIf filters to make decisions in your workflow. If this attribute has a value, you can then redirect the person to the existing workflow instance and then have the 'current' instance just delete itself. If this attribute is blank, however, then you want to set it for future reference.From here, the workflow would just continue on its merry way. As long as this UserPreference value is set for a person, duplicates (or any additional instances of this Workflow Type) would not be possible. So, we need to make sure we clear this value at some point in our workflow so that this person can create a new instance at some point in the future, if needed. This would most likely happen at/near the end of the workflow process.With this, the UserPreference is cleared and the person could create a new workflow instance for this particular workflow type again, if needed.