Workflow is the object-level container for workflow rules and their action definitions. Rules evaluate record conditions and initiate field updates, email alerts, tasks, outbound SOAP messages, and supported Flow or Knowledge publishing actions. A rule can invoke actions immediately or through time-based triggers.
There is one Workflow component per standard or custom object that has workflow configuration. The container's identity is the full object name, including any namespace; individual rules and actions have separate identities within that context. This metadata is not a Flow definition, and it does not contain the runtime queue of pending time-based actions.
Key Elements
| Element | What the Element Controls |
|---|---|
rules.active, rules.triggerType
|
Whether a rule is active and when it is evaluated. Documented evaluation values are onCreateOnly, onAllChanges, and onCreateOrTriggeringUpdate. The exposed value OnRecursiveUpdate has no defined semantics in the workflow rule behavior documentation. |
rules.criteriaItems, rules.formula, rules.booleanFilter
|
Conditions for firing the rule. Either criteriaItems or formula must be set. booleanFilter combines numbered criteria, such as (1 AND 2) OR 3. |
rules.actions, rules.workflowTimeTriggers.actions
|
Immediate and scheduled action selections. Each reference uses name and type to identify a named action; an action definition alone does not make a rule invoke it. |
fieldUpdates.operation |
How the new field value is calculated. Values are Formula, Literal, LookupValue, NextValue, Null, and PreviousValue. The operation must match the target field and the corresponding value element. |
fieldUpdates.reevaluateOnChange |
When true, an actual value change causes all workflow rules on the associated object to be reevaluated. Further qualifying field updates can continue the cascade up to five times after the initial update. |
fieldUpdates.field, fieldUpdates.targetObject
|
The updated field and, for a child-driven parent update, the child's foreign-key reference to the parent. targetObject is not an arbitrary destination object name. |
rules.workflowTimeTriggers.offsetFromField, timeLength, workflowTimeTriggerUnit
|
The date anchor and scheduling offset. Units are Hours or Days; a negative timeLength schedules before the anchor. |
tasks.dueDateOffset, tasks.offsetFromField
|
The created task's due date, not action execution time. The offset is in days from the trigger date or the optional date field and can be negative. |
tasks.assignedTo, tasks.assignedToType
|
Task assignment. The value must agree with the assignee type. Explicit roles use role names; explicit users and partner users use usernames. |
alerts.recipients, alerts.ccEmails
|
Email destinations. Successful delivery requires recipients, additional addresses, or both. ccEmails permits up to five addresses. |
alerts.template |
The required EmailTemplate reference. The template must exist in the destination Metadata API environment, but need not be in the same deployment archive. |
alerts.senderType, alerts.senderAddress
|
From and Reply-To behavior. Values are CurrentUser, DefaultWorkflowUser, and OrgWideEmailAddress. Only OrgWideEmailAddress permits senderAddress. |
outboundMessages.endpointUrl, fields, integrationUser, includeSessionId, apiVersion
|
The external destination, selected payload fields, sending user, inclusion of a Salesforce session credential, and API contract used for callbacks to Salesforce. |
flowActions.flow, flowActions.flowInputs
|
The Flow to launch and values passed to input-enabled variables. These workflow actions are restricted to organizations that already enabled the closed pilot. |
knowledgePublishes.action |
The publishing operation: PublishAsNew publishes a new article; Publish publishes a version of an already published article. |
Behavior and Constraints
Rule evaluation and action selection
Read active, triggerType, and the rule criteria together. onCreateOnly evaluates on creation, onAllChanges evaluates on all changes, and onCreateOrTriggeringUpdate evaluates on creation and triggering updates.
rules.actions identifies immediate actions. Each entry under rules.workflowTimeTriggers has its own separately scheduled actions collection. These references connect rules to named WorkflowAlert, WorkflowFieldUpdate, WorkflowFlowAction, WorkflowKnowledgePublish, WorkflowOutboundMessage, and WorkflowTask definitions. Inspect the references rather than assuming that every action in the container is used by every rule.
Field dependencies also occur outside action definitions. Rule formulas and field-update formulas can contain field references, and filter entries can identify fields through criteriaItems.field and valueField. An inventory limited to action names misses fields that determine whether a rule fires or what value it writes.
Field updates and reevaluation
Set the value element that corresponds to fieldUpdates.operation:
-
Formulauses a validformula. -
Literaluses aliteralValuecompatible with the target field. -
LookupValuerequireslookupValue. Its supported target types have a documentation discrepancy described below. -
NextValueandPreviousValueapply only to picklists. -
Nullsets the field to null.
reevaluateOnChange=true has an effect only when the update actually changes the field value. It then reevaluates all workflow rules on the associated object, and rules whose criteria are met can fire. If those rules produce further field updates that also enable reevaluation, the cascade can continue up to five times after the initial field update.
For a parent update initiated by a child record, follow both the relationship field and the parent object context. For example, EmailMessage.ParentId identifies the Case parent. Inspecting only fieldUpdates.field is not enough to identify the affected record.
Time triggers and task due dates
A time trigger combines offsetFromField, timeLength, and workflowTimeTriggerUnit. The date anchor can be a supported record date, the rule trigger date, or a custom date field. Negative offsets represent time before the anchor.
A task's dueDateOffset is a separate calculation. It determines the due date of the task created by the action; it does not delay the action itself. Task definitions also specify the created task's priority, status, and subject. notifyAssignee controls the assignment email notification.
Pending execution is runtime state, not part of the Workflow definition. The WorkflowTimeQueue runtime object discussed in queue-management reports is distinct from this metadata container.
Email recipients and senders
The meaning of an alert recipient depends on recipients.type:
-
contactLookupusesrecipients.fieldto identify a Contact reference. -
emailusesrecipients.fieldto identify an email field. -
userLookupusesrecipients.fieldto identify a User foreign-key field. - Group and role-based selections use
recipients.recipientto identify the group or role. - Explicit
userandpartnerUserselections identify users by username, not by a metadata developer name.
senderType controls both From and Reply-To. CurrentUser, the default, uses the email address of the person updating the record. DefaultWorkflowUser uses the default workflow user's address. OrgWideEmailAddress uses a verified organization-wide address and is the only setting that accepts senderAddress.
Outbound messages and authentication
An outbound message sends the selected fields to endpointUrl using SOAP, an XML-based messaging protocol. integrationUser identifies the user under which the message is sent. When includeSessionId is enabled, the payload includes the Salesforce session ID so the receiver can make API callbacks without supplying a username and password. Together, these settings identify an external data destination and whether an authentication credential travels with the payload.
The stored apiVersion controls callbacks to Salesforce using enterprise or partner WSDLs, the service descriptions used by the receiving integration. Salesforce sets it to the current API version when the outbound message is created. Only Metadata API can change it; the Salesforce UI cannot. Changing it to a version that does not support a configured field is a documented cause of message failures requiring the listener to consume the updated WSDL.
useDeadLetterQueue is available only when the organization has dead letter queue permissions enabled. When set, it uses that queue if normal delivery fails. Monitor outbound-message status separately in Setup under Outbound Messages.
Flow and Knowledge actions
flowActions launches the Flow named by flow, but only in organizations that already enabled the closed flow-trigger workflow-action pilot. The presence of this element does not make the capability available in other organizations. Use a record-triggered flow outside those pilot-enabled organizations.
Each flowInputs.name must identify a Flow variable with isInput enabled. For an sObject variable, which holds a Salesforce record, value must be a merge field identifying a record or a lookup relationship to a record of the same object type. Merge fields are expressions that supply record or global-variable values at runtime. Other variable types accept compatible merge fields or literal values.
knowledgePublishes.action performs an actual publishing operation. Choosing PublishAsNew instead of Publish changes whether the action publishes a new article or a version of an already published article.
Deployment and Retrieval
Metadata API package files use the .workflow suffix in the workflows directory, such as workflows/Opportunity.workflow. The entire file base is the associated object name. Preserve namespaces and the full object API name rather than applying an individual action's developer-name rules to the container.
In package.xml, use the object name as the member for Workflow. To retrieve all Workflow components, use the supported wildcard:
<types><members>*</members><name>Workflow</name></types>
An object-specific member, such as Opportunity, selects that object's container, not a rule with that name. The Workflow Metadata API reference describes the container and its child definitions.
Concrete dependencies depend on the configured values: referenced actions, fields, relationship fields, flows, email templates, groups, roles, and named users can all matter. The object-based naming association alone does not establish a mandatory deployment sequence, require both components in the same archive, or authorize deleting the associated object.
For packaged email alerts, Lightning email templates are not packageable; Classic email templates are recommended. The referenced template must exist in the destination, even when it is not included in the deployment archive. Package installation also changes an alert's senderType from DefaultWorkflowUser to CurrentUser, which can change the effective sender without another visible change to the alert.
For alerts, field updates, outbound messages, tasks, and Knowledge publishing actions, protected=true prevents components created in the installing organization from linking to or referencing the protected action. This is a managed-package reference restriction, not record-level access control. flowActions.protected is reserved for future use and does not carry that documented meaning.
Flow-trigger test mode is not supported by Metadata API. To run the latest Flow version in test mode when an administrator causes the workflow to fire, enable that mode through the UI after deployment.
Distinguish destructive changes to the container from deletion of its children. A reported destructive deployment rejected deletion addressed to the object-level Workflow container and instead required individual rules and actions. The accepted example used WorkflowRule with an object-qualified member such as Custom_Object__c.MyRule; WorkflowTask could require separate deletion. Do not assume container deletion removes everything inside it.
Schema exposure alone also does not establish creation availability. The reported absence of new-rule creation in Setup does not establish a blanket prohibition on Metadata API deployment or creation of every workflow action type.
Relationships
Workflow contains rule and action definitions. Rule action references select named actions; other elements connect configuration to fields, flows, templates, groups, and roles. User selections are named-user dependencies, often expressed as usernames, rather than metadata developer names. The following are possible element-reference connections, not proof that every Workflow component uses them.
References
-
CustomField:field,fields,formula,offsetFromField,targetObject,valueField. -
CustomObject:targetObject, for the parent object context of a relationship-based update. -
EmailTemplate:template. -
Flow:flow. -
Group:field,recipient. -
Queue:lookupValue, subject to the lookup-operation discrepancy below. -
RecordType:lookupValue, subject to the lookup-operation discrepancy below. -
Role:assignedTo,field,recipient. -
WorkflowAlert: action-referencename. -
WorkflowFieldUpdate: action-referencename. -
WorkflowFlowAction: action-referencename. -
WorkflowKnowledgePublish: action-referencename. -
WorkflowOutboundMessage: action-referencename. -
WorkflowTask: action-referencename.
Name-based association: Separately from these element references, the complete Workflow file base follows <objectName> and identifies the associated CustomObject metadata context. That context can be a standard or custom object; the association does not imply that a new custom object must be created.
Documentation Inconsistencies
-
Lookup assignments have conflicting support signals.
lookupValueTypeexposesQueue,RecordType, andUser, andlookupValuehas recognized Queue and RecordType associations. However, theLookupValueoperation documentation states that only User is supported. The broader enumeration is not assurance that arbitrary lookup assignments work. -
The portal-recipient token differs. The exposed enumeration uses
customerPortalUser, while theWorkflowEmailRecipientdocumentation listscustomerPortalOwner. Do not assume the spellings are interchangeable. -
A trigger value lacks defined behavior. The exposed
triggerTypeenumeration includesOnRecursiveUpdate, but the workflow rule behavior documentation does not define its semantics. Do not infer its behavior solely from its name.
Reported Issues
-
An integration can observe an intermediate value or miss a workflow reversal. A 2020 report describes update triggers running again after a workflow field update, while
Trigger.oldretains values from before the initial update rather than immediately before the workflow update. Comparing old and new values can therefore miss a field being restored to its original value. Trigger change-detection discussion. -
Pending actions may require manual removal or a source-record change. A 2018 discussion reports that direct manipulation of
WorkflowTimeQueuewas unavailable through Apex or API. The reported alternatives were removal in Setup's Time-Based Workflow monitor or editing the source record so it no longer met the rule's criteria, which removed that rule's pending actions. Pending-action removal discussion. - Late time-based actions are not necessarily lost. A 2016 discussion reports batched processing and hourly processing limits that defer excess time triggers rather than discard them. The configured scheduled time can therefore differ from observed execution time. Time-trigger delay discussion.
-
A destructive change addressed to the container can be rejected. A 2012 report required rules and actions to be deleted individually instead of deleting the object-level
Workflowcomponent. Its accepted example used an object-qualifiedWorkflowRulemember and noted that tasks might need separate deletion. Destructive-deployment discussion. - New-rule creation may be unavailable in Setup even though workflow elements remain exposed. A December 2022 report states that new-rule creation was disabled in the UI. It does not establish that all Metadata API workflow deployments or action-creation operations are prohibited. Creation-availability discussion.
-
A formula can be rejected because of its evaluation mode. A 2016 report describes
ISCHANGEDbeing rejected with the mode corresponding toonCreateOrTriggeringUpdate. The discussion also distinguishes any change from a directional change: detecting a checkbox transition to true requires checking the resulting value as well, for exampleAND(ISCHANGED(Active__c), Active__c = TRUE). ISCHANGED evaluation discussion. -
An active-only Tooling API update can clear omitted values or fail. A 2021 report warns against updating a child
WorkflowRule'sMetadatawith onlyactive. The reported approach retrieves and preserves the rule metadata while changing that flag. This concerns Tooling API child-rule edits, not a general replacement rule for Workflow Metadata API deployments. Activation-update discussion.
Common Questions
How do I retrieve all workflow rules for an object?
Use Workflow as the metadata type and the object's full API name as the manifest member. This retrieves the object-level container with its rules and action definitions. Use * to retrieve all Workflow components.
Why does a workflow field update cause other rules to fire?
When reevaluateOnChange is true and the update changes the field value, Salesforce reevaluates all workflow rules on the associated object. Further field updates with reevaluation enabled can continue the cascade up to five times after the initial update.
Does dueDateOffset control when a workflow task is created?
No. tasks.dueDateOffset controls the created task's due date. Immediate action references or workflowTimeTriggers determine when the task action runs.
Why did an email alert's sender change after package installation?
Package installation changes senderType from DefaultWorkflowUser to CurrentUser. That changes the address used for both From and Reply-To.
Can I delete every rule by deleting the Workflow container?
Do not rely on that approach. Reported destructive-deployment behavior required deleting rules and actions individually, using child types and object-qualified members such as WorkflowRule with Custom_Object__c.MyRule. Tasks could require separate deletion.