No, you cannot disable workflows via Apex code to my knowledge.
What you can do is look at your use case, and modify the worklow not to fire for your special logic.
Think about it. If your were able to disable a wokflow, its possible you could have multiple transactions occuring at the same time and if you disabled the worklflow in one trigger, that could impact other concurrent transactions which expected the workflow to fire.
Thx for the reply. I also thought about a mechanism to add in my workflow so that i can run or not run. But my use case is a bit different
i want the trigger on a certain custom object and lets say that the outcome of that trigger is true i want to disable a workflow on a totally different custom object so that it won't run in the future.
But i will try to find a solution by updating a field or anything like that where the workflow can check on.
No, you cannot disable workflows via Apex code to my knowledge.
What you can do is look at your use case, and modify the worklow not to fire for your special logic.
Think about it. If your were able to disable a wokflow, its possible you could have multiple transactions occuring at the same time and if you disabled the worklflow in one trigger, that could impact other concurrent transactions which expected the workflow to fire.
Hi Cory
Thx for the reply. I also thought about a mechanism to add in my workflow so that i can run or not run. But my use case is a bit different
i want the trigger on a certain custom object and lets say that the outcome of that trigger is true i want to disable a workflow on a totally different custom object so that it won't run in the future.
But i will try to find a solution by updating a field or anything like that where the workflow can check on.
Thx for the reply
Greets
Sven