I'm trying to delete all of the worflow rules & triggered tasks associated with a custom object, using the Force.com Migration Tool, but I keep getting errors.
First I tried to submit blank workflow metadata use the following destructiveChanges.xml
:
<?xml version="1.0" encoding="UTF-8"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
<types>
<members>Custom_Object__c</members>
<name>Workflow</name>
</types>
<version>26.0</version>
</Package>
...but I get this error:
BUILD FAILED
C:\Users\...\build.xml:69: FAILURES:
Error: workflows/Custom_Object__c.workflow(Custom_Object__c):Cannot delete a workflow
object; Workflow Rules and Actions must be deleted individually
But when I tried to list the indivual rules and actions in the <members>
lists, I got an error that those workflow components couldn't be found.
How can I delete these? I'm trying to avoid having to go into each workflow rule, deactivate it, then deleting the field updates, and finally deleting the workflow rules.
Attribution to: Benj
Possible Suggestion/Solution #1
Workflow Rules have their own component type, as do Workflow Tasks, try this...
<?xml version="1.0" encoding="UTF-8"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
<types>
<members>Custom_Object__c.MyRule</members>
<name>WorkflowRule</name>
</types>
<version>26.0</version>
</Package>
You may have to do this for WorkflowTask's as well.
Follow up question via comment below...
The WorkflowRule and WorkflowTask appear in the package folder structure as follows. They basically use the /workflows folder and the .workflow file extension. You can read more about them in the Metadata API developers guide here.
P.S. If your interested in the above code it is here.
Attribution to: Andrew Fawcett
This content is remixed from stackoverflow or stackexchange. Please visit https://salesforce.stackexchange.com/questions/4776