2

The question is basically as in the title: Is it possible to create a new WorkflowRule using Metadata API?

I'm using Java, and I want to create a workflow rule for a custom object. I've tried: * Creating a new WorkflowRule object, but couldn't find anything which could attach it to a "parent" * The same with Workflow objects. * CustomObject also doesn't have anything like "setWorkflowRules()"

What am I missing here?

2

Workflows are supported by the Metadata API. The Documentation is provided here: https://www.salesforce.com/us/developer/docs/api_meta/

Each Object you have on an Org should have already a matching Workflow:

Workflow files have the suffix .workflow. There is one file per standard or custom object that has workflow. These files are stored in the workflows directory of the corresponding package.

It seems that you have to match fullName to e. g. YourObjectName__c.workflow or Account.workflow

So you need to query the existing Workflow for your object and add the rules, fieldUpdates and tasks there.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.