What Is Workflow Rules In Salesforce?
Workflow is a Salesforce platform business logic engine that allows defining rules to automate certain actions when particular criteria are met.
Starting in Winter ’23, Salesforce is blocking the creation of workflow rules. You can still activate, deactivate, and edit any existing workflow rules. To test and create workflow rules for use in managed packages, developer orgs still allow you to create workflow rules. For new automation, use flows.
Salesforce Workflow Rules Components
Workflow rules are considered as a container that consists of two components:
It consists of the condition which if found true then the actions should take place.
It consists of the actions that should be performed when the criteria for workflow rule are met.
Every Workflow rule must be based on a single object because when a rule is defined this object influences the fields that will be available to set the criteria.
Evaluation Criteria For Workflows
There are 3 types of evaluation criteria for workflows:
Evaluate the rule when a record is
|Created|| Runs the rule if the rule criteria are met, only when a record is created.
Using this option the rule runs single time only.
|Created & Every time it is edited|| Runs the rule if the criteria are met every time a record is created and edited. With this option, the rule criteria run repeatedly as long as the rule criteria are met.
Note: Time-Dependent actions cannot be added to a workflow rule with this evaluation criteria.
|Created and Every time it’s edited to subsequently meet the criteria|| Runs the rule if the criteria are met:
By default, these criteria are selected.
Criteria for rules can be represented as a condition or a formula.
Actions In Workflow Rules
Actions in workflow rules are of 2 types based on when they are executed:
1. Immediate Actions
These actions are executed immediately when the criteria for a rule are met.
2. Time-Triggered Actions
These actions execute at a specific time which is specified when creating this type of action. In these types of actions when the date or time comes on which the action needs to be executed, it again verifies whether the record is still meeting the criteria or not. If yes then it executes the respective action otherwise not.
Types Of Actions Available In Workflow Rule
There are 4 actions specified in a Workflow Rule:
1. Email Alert
It sends automated emails using an email template. Salesforce provides functionality to create email templates that can be used to send emails.
There are 4 types of Classic Email templates:
- Text: All users can create or change text email templates.
- HTML with Classic letterhead: Administrators and Users with “Edit HTML Templates” permission can create HTML email templates based on a letterhead
- Custom HTML: Administrators and users with “Edit HTML Templates” permission can create HTML email templates without using a letterhead.
- Visualforce: Administrators & Developers can create templates using Visualforce. Visualforce email templates allow for advanced merging with a recipient’s data where the content of a template can contain information from multiple records.
Email templates are stored in folders. There are 2 folders already present in every Salesforce org:
- Unified public Email Templates: Email Templates in this folder are available to every user in the organization.
- My Email Templates: This folder stores the email templates which are used personally by a particular user.
If another object’s field is added in an email template then it will be left blank as workflow only has access to the object for which it is applied.
2. Field Update
Field updates allow the user to automatically change a field value on the record that initially triggered the workflow rule.
If “Re-evaluate Workflow Rules after Field Change” is enabled for a field update action then Salesforce re-evaluates all workflow rules on the object if the field update results in a change to the value of the field.
Only workflow rules that didn’t fire before will be retriggered.
Cross Object field updates are also available for changing the values of fields on a related master record. But it is not available when re-evaluation is checked.
It simply assigns a task to a single user, owner, or role. We can also make sure that a notification email is sent to the assignee when a task is automatically assigned.
Tasks should be assigned to roles if they have only one user assigned to that role. If there is more than one user assigned to that role then the task automatically gets assigned to the owner of the workflow rule. (Users who triggered the workflow rule)
4. Outbound Message
An outbound message sends particular information to a designated endpoint such as an external service. These types of messages can be listened to using SOAP API. All the above actions can be used as immediate actions as well as time trigger actions.
Time-triggered actions which are already triggered are visible in Time Based Workflow Queues.
Administrators can also set default workflow users. Default Workflow users are the users who will be visible when the user that triggered the rule is not active.
- Time-trigger actions cannot be added to active workflows. To add a time trigger action first deactivate the workflow rule then add an action.
- Another time trigger cannot be added if there is already a time trigger action scheduled for that object and present in the time-based workflow queue.
- The action a workflow rule takes can also trigger the execution of another workflow rule.