Workflow
Represents the metadata associated with a workflow rule. A workflow rule sets workflow actions into motion when its designated conditions are met. You can configure workflow actions to execute immediately when a record meets the conditions in your workflow rule, or set time triggers that execute the workflow actions on a specific day. Use this metadata type to create, update, or delete workflow rule definitions.
For more information, see Workflow in Salesforce Help.
When using a manifest file, retrieve all workflow components using this code.
This metadata type represents the valid types of workflow rules and actions associated with a standard or custom object.
This type extends Metadata and inherits its fields.
Workflow files have the suffix .workflow. There’s one file per standard or custom object that has workflow. These files are stored in the workflows directory of the corresponding package.
Workflow rules are available in API version 13.0 and later.
- Type: WorkflowAlert[]
- Required: No
- Description: An array of all alerts for the object associated with the workflow.
- Type: WorkflowFieldUpdate[]
- Required: No
- Description: An array of all field updates for the object associated with the workflow.
- Type: WorkflowFlowAction[]
- Required: No
- Introduced: API version 30.0
- Description: An array of flow triggers for the object associated with the workflow. The pilot program for flow trigger workflow actions is closed. If you already enabled the pilot in your org, you can continue to create and edit flow trigger workflow actions. If you didn’t enable the pilot, use Flow Builder to create a record-triggered flow, or use Process Builder to launch a flow from a process.
- Type: WorkflowFlowAutomation[]
- Required: No
- Type: string
- Required: No
- Description: The developer name used as a unique identifier for API access. The
fullNamecan contain only underscores and alphanumeric characters. It must be unique, begin with a letter, not include spaces, not end with an underscore, and not contain two consecutive underscores. This field is inherited from the Metadata component.
- Type: WorkflowKnowledgePublish[]
- Required: No
- Introduced: API version 27.0
- Description: An array of Salesforce Knowledge Workflow Publishes associated with the workflow.
- Type: WorkflowOutboundMessage[]
- Required: No
- Description: An array of all the outbound messages for the object associated with the workflow.
- Type: WorkflowRule[]
- Required: No
- Description: An array of all the objects associated with the workflow.
- Type: WorkflowSend[]
- Required: No
- Type: WorkflowTask[]
- Required: No
- Description: An array of all the tasks for the object associated with the workflow.
WorkflowActionReference represents one of the workflow actions.
- Type: string
- Required: Yes
- Description: Required. The name of the workflow action.
-
Type: WorkflowActionType (enumeration of type string)
-
Required: Yes
-
Description: Required. Available types of workflow actions:
The pilot program for flow trigger workflow actions is closed. If you already enabled the pilot in your org, you can continue to create and edit flow trigger workflow actions. If you didn’t enable the pilot, use Flow Builder to create a record-triggered flow, or use Process Builder to launch a flow from a process.
-
Possible values:
- Alert
- FieldUpdate
- FlowAction — Available in API version 30.0 and later
- OutboundMessage
- Task
WorkflowAlert represents an email alert associated with a workflow rule.
This type extends WorkflowAction and inherits its fields.
-
Type: string[]
-
Required: No
-
Description: Additional email addresses. This field is similar to the CC field in email clients.
For the email to be sent successfully, set a value for
ccEmailsorrecipients. You can set values for both fields. The value ofccEmailscan include up to 5 different email addresses.
- Type: string
- Required: Yes
- Description: A description of this component. The description should explain the component’s purpose and behavior so that administrators and developers understand when to use it.
- Type: string
- Required: No
- Description: Required. The developer name used as a unique identifier for API access. The
fullNamecan contain only underscores and alphanumeric characters. It must be unique, begin with a letter, not include spaces, not end with an underscore, and not contain two consecutive underscores. This field is inherited from the Metadata component.
- Type: boolean
- Required: Yes
- Description: Required. Indicates whether this component is protected (
true) or not (false). Protected components can’t be linked to or referenced by components created in the installing organization.
-
Type: WorkflowEmailRecipient[]
-
Required: No
-
Description: The recipients for the email.
For the email to be sent successfully, set a value for
ccEmailsorrecipients. You can set values for both fields.
- Type: string
- Required: No
- Description: The address in the From field for the email alert. With this address, you can use a standard global email address for your organization, such as
support@company.com, instead of the default From field, which is the email address of the person who updates the record. You can only specify a value in this field if thesenderTypeis set toOrgWideEmailAddress. See Organization-Wide Email Addresses in Salesforce Help.
- Type: ActionEmailSenderType (enumeration of type string)
- Required: No
- Description: The email used as the sender’s From and Reply-To addresses. These values are valid.
- Possible values:
- CurrentUser — The email address of the person updating the record. This value is the default setting.
- DefaultWorkflowUser — The email address of the default workflow user. If the email alert is installed from a package, this field value is changed to
CurrentUser. - OrgWideEmailAddress — A verified global email address for your organization, such as
support@company.com.
-
Type: string
-
Required: Yes
-
Description: Required. Named reference to an EmailTemplate. This email template isn’t required to exist in the zip file, but it must exist in Metadata API.
Lightning email templates aren’t packageable. We recommend using a Classic email template.
WorkflowEmailRecipient represents a recipient for an email alert associated with a workflow rule.
- Type: string
- Required: No
- Description: Name of the field referenced in
type. The field named is of the type specified intype.
- Type: string
- Required: No
- Description: The recipients for the email. Depending on the type selected, this field is required.
- Type: ActionEmailRecipientTypes (enumeration of type string)
- Required: Yes
- Description: Named reference to an EmailTemplate component.
- Possible values:
- accountOwner — The email is sent to the record’s account owner. For example, the Account owner for an Opportunity.
- accountTeam — Only applicable on the Account object. The email is sent to everyone on that Account’s account team.
- campaignMemberDerivedOwner — Emails are sent to lead and contact owners when contacts are added to a campaign or in response to a campaign.
- contactLookup — The email is sent to a contact whose value is looked up from a field on the record. For this value, the
fieldfield must reference a Contact. - creator — The email is sent to the record’s creator.
- customerPortalOwner — The email is sent to a specific self-service portal user. For this value, the recipient field must reference a self-service portal user by their username.
- email — The email is sent to an email address whose value is looked up from a field on the record. For this value, the
fieldfield must reference an email field. - group — The email is sent to all users in a group. For this value, the recipient field must reference a group by group name.
- opportunityTeam — Only applicable on the Opportunity object. The email is sent to everyone on that Opportunity’s opportunity team.
- owner — The email is sent to the record’s owner.
- partnerUser — The email is sent to a specific partner user. For this value, the recipient field must reference a partner user by username.
- portalRole — Like
role, but for portal roles only. - portalRoleSubordinates — Like
roleSubordinates, but for portal roles only. - role — The email is sent to all users in a role. For this value, the recipient field must reference a role name in the role hierarchy.
- roleSubordinates — The email is sent to all users in a role subordinate. For this value, the recipient field must reference a role.
- roleSubordinatesInternal — Like
roleSubordinates, but for internal portal roles only. - user — The email is sent to a specific user. For this value, the recipient field must reference a user by username.
- userLookup — The email is sent to a user whose value is looked up from a field on the record. For this value, the
fieldfield must reference a user foreign key field.
WorkflowFieldUpdate represents a workflow field update. With field updates, you can automatically update a field value to one that you specify when a workflow rule is triggered.
This type extends WorkflowAction and inherits its fields.
- Type: string
- Required: No
- Description: The description of the field update. This information is useful to track the reasoning for initially configuring the field update.
- Type: string
- Required: Yes
- Description: Required. The field on the object for the workflow to be updated.
- Type: string
- Required: No
- Description: If the
operationfield value isFormula, the formula used to compute the new field value.
- Type: string
- Required: No
- Description: Required. The developer name used as a unique identifier for API access. The
fullNamecan contain only underscores and alphanumeric characters. It must be unique, begin with a letter, not include spaces, not end with an underscore, and not contain two consecutive underscores. This field is inherited from the Metadata component.
- Type: string
- Required: No
- Description: If the
operationfield value isLiteral, the literal value for the field.
- Type: string
- Required: No
- Description: If the
operationfield value islookupValue, the lookup value that is referenced.
- Type: LookupValueType (enumeration of type string)
- Required: No
- Description: The type of object that the
lookupValuefield value is referencing. - Possible values:
- Queue
- RecordType
- User
- Type: string
- Required: Yes
- Type: boolean
- Required: Yes
- Description: Required. Notify the assignee when the field is updated.
- Type: FieldUpdateOperation (enumeration of type string)
- Required: Yes
- Description: Required. The operation that computes the value with which to update the field.
- Possible values:
- Formula — Indicates the field is set to a formula. If set, the formula must be a valid formula.
- Literal — Indicates the field is set to a literal value. If set, the literalValue must be a valid literal value for this field.
- LookupValue — Similar to Literal, but for an object reference, such as a contact, user, or account. If set, the
lookupValueelement must be set. Only User is supported in the current API. - NextValue — Indicates that the field will be set to its next value. Only allowed when the field update references a picklist.
- Null — Indicates that the field is set to null.
- PreviousValue — Indicates that the field is set to its previous value. Only allowed when the field update references a picklist.
- Type: boolean
- Required: Yes
- Description: Required. Indicates whether this component is protected (
true) or not (false). Protected components can’t be linked to or referenced by components created in the installing organization.
-
Type: boolean
-
Required: No
-
Description: When set to
true, if the field update changes the field’s value, all workflow rules on the associated object are reevaluated. Any workflow rules whose criteria are met as a result of the field value change are triggered.If any of the triggered workflow rules result in another field update that’s also enabled for workflow rule reevaluation, a domino effect occurs, and more workflow rules can be reevaluated as a result of the newly triggered field update. This cascade of workflow rule reevaluation and triggering can happen up to 5 times after the initial field update that started it.
- Type: string
- Required: No
- Description: Object set if the change is detected on a child record. If set, the object points to the foreign key reference on the child object that points to the parent. For example, if
EmailMessagechild record is changed,EmailMessage.ParentIdpoints to theCaseparent. This field is namedsourceFieldbefore version 14.0. The field name change is automatically handled between versions and doesn’t require any manual editing of existing XML component files.
Represents a flow trigger, which is a workflow action that launches a flow. For more information, see these topics in Salesforce Help.
- Define a Flow Trigger for Workflow (Pilot)
- Flow Trigger Considerations (Pilot)
- The pilot program for flow trigger workflow actions is closed. If you already enabled the pilot in your org, you can continue to create and edit flow trigger workflow actions. If you didn’t enable the pilot, use Flow Builder to create a record-triggered flow, or use Process Builder to launch a flow from a process.
- Test mode for flow triggers isn’t supported in the Metadata API. If you want a flow trigger to run the latest flow version when an administrator causes the workflow rule to fire, enable test mode via the user interface after deployment.
This type extends WorkflowAction and inherits its fields.
Introduced in API version 30.0.
The pilot program for flow trigger workflow actions is closed. If you already enabled the pilot in your org, you can continue to create and edit flow trigger workflow actions. If you didn’t enable the pilot, use Flow Builder to create a record-triggered flow, or use Process Builder to launch a flow from a process. Test mode for flow triggers isn’t supported in the Metadata API. If you want a flow trigger to run the latest flow version when an administrator causes the workflow rule to fire, enable test mode via the user interface after deployment.
- Type: string
- Required: No
- Description: Describes the flow trigger.
- Type: string
- Required: Yes
- Description: Required. API name of the flow that this workflow action launches.
- Type: WorkflowFlowActionParameter[]
- Required: No
- Description: An array of values to pass into flow variables when launching the flow.
- Type: string
- Required: Yes
- Description: Required. Name of the flow trigger.
- Type: string
- Required: No
- Description: Reserved for future use.
- Type: boolean
- Required: Yes
- Description: Reserved for future use.
Represents a value specified in the flow trigger that is passed into a variable when launching the flow.
The pilot program for flow trigger workflow actions is closed. If you already enabled the pilot in your org, you can continue to create and edit flow trigger workflow actions. If you didn’t enable the pilot, use Flow Builder to create a record-triggered flow, or use Process Builder to launch a flow from a process.
The pilot program for flow trigger workflow actions is closed. If you already enabled the pilot in your org, you can continue to create and edit flow trigger workflow actions. If you didn’t enable the pilot, use Flow Builder to create a record-triggered flow, or use Process Builder to launch a flow from a process.
-
Type: string
-
Required: Yes
-
Description: Required. API name of the flow variable.
The flow variable must have
isInputset toTrue.
-
Type: string
-
Required: No
-
Description: Required. Value to assign to the flow variable when launching the flow.
If the variable’s data type is sObject,
valuemust be a merge field that identifies a record—or a lookup relationship field that references a record—of the same object type as the variable. For example:{!this}—Identifies the record that fired the workflow rule.{!Contact}—Identifies the contact associated with the record that fired the workflow rule.{!Asset.Account}—Identifies the account associated with the asset that is associated with the record that fired the workflow rule.{!SomeObject__r}—Uses a lookup relationship field to identify a custom object record associated with the record that fired the workflow rule.
For variables of other data types, you can enter a merge field or a literal value. Manually enter a literal value when the variable requires the same value every time the flow is launched, regardless of which record fired the workflow rule. For example, you can enter
trueorfalsefor a variable of type Boolean.Supported merge fields identify a global variable or a field of the same data type as the flow variable. For example:
{!Id}—ID of the record that fired the workflow rule.{!Account.Owner.Email}—Email address of the account owner for the account associated with the record that fired the workflow rule.{!$Organization.Country}—Country of the organization.
This type extends WorkflowAction and inherits its fields.
- Type: string
- Required: No
- Type: string
- Required: No
- Type: string
- Required: No
- Type: string
- Required: No
- Type: boolean
- Required: No
- Type: string
- Required: No
- Type: string
- Required: No
- Description: The master label for this component. This display value is the internal label that isn’t translated.
- Type: string
- Required: No
- Type: string
- Required: No
WorkflowKnowledgePublish represents Salesforce Knowledge article publishing actions and information.
This type extends WorkflowAction and inherits its fields.
Introduced in API version 27.0.
- Type: KnowledgeWorkflowAction (enumeration of type string)
- Required: Yes
- Description: Required. The article publishing actions available when this rule fires.
- Possible values:
- PublishAsNew — Publishes the article as a new article.
- Publish — Publishes the article as a version of a previously published article.
- Type: string
- Required: No
- Description: A brief article description.
- Type: string
- Required: Yes
- Description: Required. Label that represents the article throughout the Salesforce user interface.
- Type: string
- Required: No
- Description: The language of the article.
- Type: boolean
- Required: Yes
- Description: Required. Indicates whether this component is protected (
true) or not (false). Protected components can’t be linked to or referenced by components created in the installing organization.
WorkflowOutboundMessage represents an outbound message associated with a workflow rule. Outbound messages are workflow and approval actions that send the information you specify to an endpoint you designate, such as an external service. An outbound message sends the data in the specified fields in the form of a SOAP message to the endpoint. For more information, see Outbound Message Actions in Salesforce Help.
This type extends WorkflowAction and inherits its fields.
-
Type: double
-
Required: Yes
-
Introduced: API version 18.0
-
Description: Required. The API version of the outbound message. Automatically set to the current API version when the outbound message is created. Valid API versions for outbound messages are 8.0 and 18.0 or later.
This API version is used in API calls back to Salesforce using the enterprise or partner WSDLs. The
API Versioncan only be modified by using Metadata API. It can’t be modified using the Salesforce user interface. If you change theapiVersionto a version that doesn’t support one of thefieldsconfigured for the outbound message, the messages fail until you update your outbound message listener to consume the updated WSDL.To monitor the status of outbound messages, from Setup, in the Quick Find box, enter
Outbound Messages, and then select Outbound Messages inSalesforce.
- Type: string
- Required: No
- Description: Describes the outbound message.
- Type: string
- Required: Yes
- Description: Required. The endpoint URL to which the outbound message is sent.
- Type: string[]
- Required: No
- Description: The named references to the fields to be sent.
- Type: string
- Required: No
- Description: Required. The developer name used as a unique identifier for API access. The
fullNamecan contain only underscores and alphanumeric characters. It must be unique, begin with a letter, not include spaces, not end with an underscore, and not contain two consecutive underscores. This field is inherited from the Metadata component.
- Type: boolean
- Required: Yes
- Description: Required. Set if you want the Salesforce session ID included in the outbound message. Useful if you intend to make API calls and you don’t want to include a username and password.
- Type: string
- Required: Yes
- Description: Required. The named reference to the user under which this message is sent.
- Type: string
- Required: Yes
- Description: Required. A name for the component. Available in version API 16.0 and later.
- Type: boolean
- Required: Yes
- Description: Required. Indicates whether this component is protected (
true) or not (false). Protected components can’t be linked to or referenced by components created in the installing organization.
- Type: boolean
- Required: No
- Description: This field is only available for organizations with dead letter queue permissions turned on. If set, this outbound message uses the dead letter queue if normal delivery fails.
This metadata type represents a workflow rule.
This type extends Metadata and inherits its fields.
- Type: WorkflowActionReference[]
- Required: No
- Description: An array of references for the actions that happen when this rule fires.
- Type: boolean
- Required: Yes
- Description: Required. Determines if this rule is active.
- Type: string
- Required: No
- Description: For advanced criteria filter, the boolean formula. For example,
(1 AND 2) OR 3.
- Type: FilterItem[]
- Required: No
- Description: An array of the boolean criteria (conditions) under which this rule fires. Either
criteriaItemsorformulamust be set.
- Type: string
- Required: No
- Description: The description of the workflow rule.
- Type: string
- Required: No
- Introduced: API version 54.0
- Description: The API version in which a migration fails. Used as a reference to admins to retry the migration when the next version is released.
- Type: string
- Required: No
- Description: The formula condition under which this rule first must be set, either
formulaorcriteriaItems.
- Type: string
- Required: No
- Description: The developer name used as a unique identifier for API access. The
fullNamecan contain only underscores and alphanumeric characters. It must be unique, begin with a letter, not include spaces, not end with an underscore, and not contain two consecutive underscores. This field is inherited from the Metadata component.
- Type: WorkflowTriggerTypes (enumeration of type string)
- Required: Yes
- Description: Under what conditions the trigger fires.
- Possible values:
- onAllChanges — The workflow rule is considered on all changes.
- onCreateOnly — The workflow rule is considered only on create.
- onCreateOrTriggeringUpdate — The workflow rule is considered on create and triggering updates.
- Type: WorkflowTimeTrigger[]
- Required: No
- Description: Represents a set of Workflow actions, including Field Updates, Email Alerts, Outbound Messages, and Tasks, that executes before or after a specified interval of time.
This type extends WorkflowAction and inherits its fields.
- Type: SendAction (enumeration of type string)
- Required: Yes
- Type: string
- Required: No
- Description: A description of this component. The description should explain the component’s purpose and behavior so that administrators and developers understand when to use it.
- Type: string
- Required: Yes
- Description: The label that identifies this component in the Salesforce UI and in metadata listings. Character limits and translation behavior follow the enclosing type.
- Type: string
- Required: No
- Type: boolean
- Required: Yes
This metadata type references an assigned workflow task.
This type extends WorkflowAction and inherits its fields.
- Type: string
- Required: No
- Description: Specifies the user, role, or team to which the workflow rule or action is assigned. The field corresponding to the value specified here must be the same as the specified
assignedToType.
- Type: ActionTaskAssignedToTypes (enumeration of type string)
- Required: Yes
- Description: Valid string values for this type are:
- Possible values:
- accountCreator — When set, the task is assigned to the record’s account’s creator.
- accountOwner — When set, the task is assigned to the record’s account owner (Opportunity).
- accountTeam — Same as WorkflowAlert type
- creator — When set, the task is assigned to the record’s creator.
- opportunityTeam — Same as WorkflowAlert type
- owner — When set, the task is assigned to the record’s owner.
- partnerUser — When set, the
assignedTofield references a partner user by username. - portalRole — When set, the
assignedTofield references a Role by role name, a portal role. - role — When set, the
assignedTofield references a Role by role name. - user — When set, the
assignedTofield references a User by username.
- Type: string
- Required: No
- Description: The description of this workflow task.
- Type: int
- Required: Yes
- Description: Required. The offset, in days, from either the trigger date, or the date specified in the (optional)
offsetFromField. The offset can be a negative number.
- Type: string
- Required: No
- Description: Required. The developer name used as a unique identifier for API access. The
fullNamecan contain only underscores and alphanumeric characters. It must be unique, begin with a letter, not include spaces, not end with an underscore, and not contain two consecutive underscores. This field is inherited from the Metadata component.
- Type: boolean
- Required: Yes
- Description: Required. Set to send an email notification when the task is assigned.
- Type: string
- Required: No
- Description: Optional field reference of the date field from which the
dueDateis computed.
- Type: string
- Required: Yes
- Description: Required. The priority to assign the created task.
- Type: boolean
- Required: Yes
- Description: Required. Indicates whether this component is protected (
true) or not (false). Protected components can’t be linked to or referenced by components created in the installing organization.
- Type: string
- Required: Yes
- Description: Required. The status to assign the created task.
- Type: string
- Required: Yes
Represents a set of Workflow actions, including Field Updates, Email Alerts, Outbound Messages, and Tasks, that execute before or after a specified interval of time.
- Type: WorkflowActionReference[]
- Required: No
- Description: An array of references for the actions that happen when this trigger fires.
- Type: string
- Required: No
- Description: The date type field name that the time-based workflow triggers from, such as
Created Date,Last Modified Date,Rule Trigger Date, or a custom date field on the object for which the workflow rule is defined.
- Type: string
- Required: No
- Description: The numeric value of the time after or before the workflow triggers. A negative value represents the time length before the trigger fires. The
timeLengthis measured in either hours or days, as specified byworkflowTimeTriggerUnit.
- Type: WorkflowTimeUnits (enumeration of type string)
- Required: Yes
- Description: The unit of time before or after which the time-based workflow triggers. Valid string values are:
- Possible values:
- Hours
- Days
Here’s the definition of a workflow rule.
This metadata type supports the wildcard character * (asterisk) in the package.xml manifest file. For information about using the manifest file, see Deploying and Retrieving Metadata with the Zip File.