The usual process of developing a workflow is, to create a workflow on your development system, test it, pack it in a solution and transfer the solution to your productivsystem (with different levels of testing, qm, … between).
If you check the process entity after some deployments with the advanced find, you will find multiple workflows with the same name. Most of these are deactivated, usually one of them is active. Based on you deployment, each time the current process will be deactivated and defined as parent of the new workflow.
Based on this behavior, you might get a big attachment table, as if you send email with attachments in your workflow, each time you deploy a new version of your workflow, the files get added again.
Some days ago, I had the problem, that after the deployment, the parent workflow wasn’t deactivated. Means, that the new workflow was active and also the previous version of the workflow. This caused the system, to send email twice to my customers.
But there was no way to deactivate the parent workflow, as I always got an error message. I tried to delete the whole workflow, import the solution again and publish all again. But nothing changed.
In the end, I had to deactivate the workflow in the database manually. Therefore you have to update three fields of the process:
- StateCode = 0
- StatusCode = 1
Based on the documentation of MS: https://docs.microsoft.com/en-us/dynamics365/customerengagement/on-premises/developer/entities/workflow
- Type = 1
Based on these there states, the process is deactivated and can be deleted. Afterwards I imported my solution with the new workflow again, and everything worked again as expected.