Workflow in Salesforce

Workflow Rules in Salesforce

What is Salesforce Workflow Rules?

Workflow lets you automate standard internal procedures and processes to save time across your org. A workflow rule is the main container for a set of workflow instructions. These instructions can always be summed up in an if/then statement.

For Example: If you have symptoms of Coronavirus then stay at home.

Workflow rules can be broken into two main components.

  1. Criteria: the “if” part of the “if/then” statement. In other words, what must be true of the record for the workflow rule to execute the associated actions.
  2. Actions: the “then” part of the “if/then” statement. In other words, what to do when the record meets the criteria.

In the example, the criteria is “Have Coronavirus Symptoms” and the action is “Stay At home”. If the criteria isn’t met (No Symptoms), then the action isn’t executed.

Salesforce Workflow Rules

Salesforce Workflow Rules

Create a Workflow Rule

Automate your organization’s standard process by creating a workflow rule.

Demo: https://salesforce.vidyard.com/watch/IqZIFLtEx9rY7AD8QLFE3Q

Create Workflow Rules

Create Workflow Rules

Rule Criteria

Rule Criteria

Add Workflow Criteria

Remember, we are defining ‘IF’ statement criteria using Salesforce Workflow rules and When we need execute this rule.

  1. From Setup, enter Workflow Rules in the Quick Find box, then select Workflow Rules.
  2. Click New Rule.
  3. Choose the object to which you want this workflow rule to apply.
  4. Click Next.
  5. Give the rule a name and description.
  6. Set the evaluation criteria.
    • Created – Evaluate the rule criteria each time a record is created. If the rule criteria is met, run the rule. Ignore all updates to existing records.
    • Created, and every time it’s edited –Evaluate the rule criteria each time a record is created or updated. If the rule criteria are met, run the rule.
    • Created, and any time it’s edited to subsequently meet criteria-(Default) Evaluate the rule criteria each time a record is created or updated.
  7. Enter your rule criteria.
    • Choose criteria are met and select the filter criteria that a record must meet to trigger the rule. For example, set the filter to “Opportunity: Amount greater than 5000” if you want opportunity records with an amount greater than $5,000 to trigger the rule.
    • Choose formula evaluates to true and enter a formula that returns a value of “True” or “False.” Salesforce triggers the rule if the formula returns “True.”
  8. Click Save & Next.

Add Workflow Action

Once you’ve set the criteria for your workflow rule, identify what to do when those criteria are met.

Add an Immediate Action

Immediate actions, like their name suggests, are executed as soon as the workflow rule finishes evaluating the record.

Immediate Action

Immediate Action

  1. Open a workflow rule.
  2. In the Immediate Workflow Actions section, click Add Workflow Action.
  3. Select one of the options to create an action or select an existing one.

 

Below are the Workflow Actions :

  • Email Alert: Email alerts are emails generated by an automated process and sent to designated recipients. These actions consist of the standard text and list of recipients for an email. Refer Email Alert for more details
  • Field Update: Field update actions let you automatically update a field value.  Refer Field Update for more details
  • Flow Trigger: Create a flow trigger so that you can launch a flow from workflow rules. With flow triggers, you can automate complex business processes—create flows to perform logic, and have events trigger the flows via workflow rules—without writing code. For example, your flow looks up and assigns the relevant entitlement for a case.  Refer Flow Trigger for more details
  •  Outbound Message: An outbound message sends information to a designated endpoint, like an external service. You configure outbound messages from Setup. Provide the external endpoint and create a listener for the messages using the SOAP API. You can associate outbound messages with workflow rules, approval processes, or entitlement processes. Refer Outbound Message for more details.
  • Task: Task actions determine the details of an assignment given to a specified user by an automated process. You can associate task actions with workflow rules, approval processes, or entitlement processes. Refer Task for more details.

Add Time-Dependent Action

Time-dependent actions are executed at a specific time, such as 10 days before a record’s close date. When that specific time passes, the workflow rule re-evaluates the record to make sure that it still meets the rule criteria. If the record does, the workflow rule executes those actions.

Time-dependent actions and time triggers are complex features. As you work with time-dependent actions and time triggers, keep in mind their considerations.

If you plan on configuring workflow rules that have time-dependent actions, specify a default workflow user. Salesforce associates the default workflow user with a workflow rule if the user who initiated the rule is no longer active.

Add time Trigger

Add time Trigger

Define Time Trigger

Define Time Trigger

Time Dependent Workflow

Time Dependent Workflow

  1. Open a workflow rule.
  2. In the Time-Dependent Workflow Actions section, click Add Time Trigger.
    NoteNOTE You can’t add a time trigger if:
    • The evaluation criteria is set to Evaluate the rule when a record is: created, and any time it’s edited to subsequently meet criteria.
    • The rule is activated.
    • The rule is deactivated but has pending actions in the workflow queue.
  3. Specify the number of days or hours before or after a date that’s relevant to the record, such as the date the record was created.
    If the workflow rule is still active and valid when this time occurs, the time trigger fires the workflow action.
  4. Save your time trigger.
  5. In the section for the time trigger you created, click Add Workflow Action.
  6. Select one of the options to create an action or select an existing one.
  7. Click Done.

Activate Workflow Rule

Make sure to Active a workflow Rule before start unit testing.

To activate a workflow rule, click Activate on the workflow rule detail page. Click Deactivate to prevent a rule from triggering or if you want to edit the time-dependent actions and time triggers that are associated with the rule.

You can deactivate a workflow rule at any time. However, if you deactivate a rule that has pending actions, Salesforce completes those actions as long as the record that triggered the rule is not updated.

NOTE

  • You can’t delete a workflow rule that has pending actions in the workflow queue. Wait until pending actions are processed, or use the workflow queue to cancel the pending actions.
  • You can’t add time-dependent workflow actions to active workflow rules. Deactivate the workflow rule first, add the time-dependent workflow action, and reactivate the rule.

 

Things to Remember

  1. You can’t delete a workflow rule that has pending actions in the workflow queue. Wait until pending actions are processed, or use the workflow queue to cancel the pending actions.
  2. You can’t add time-dependent workflow actions to active workflow rules. Deactivate the workflow rule first, add the time-dependent workflow action, and reactivate the rule.
  3. TIP Whenever possible, automate your if/then statements with Process Builder instead of workflow rules.
  4. Remember you can also associate an existing action to multiple Workflow rules. Refer Associate Actions to Workflow Rules for more details
  5. Select a Default Workflow User that you want Salesforce to display with a workflow rule when the user that triggered the rule is not active.
    1. From Setup, enter Process Automation Settings in the Quick Find box, then select Process Automation Settings.
    2. For Default Workflow User, select a user.
    3. Save your changes.
  6. You cannot add time-dependent actions to the rule When you select ‘created, and every time it’s edited’ option during the workflow creation,
  7. In workflow Criteria,  You can use merge fields for directly related objects in workflow rule formulas.

 

Happy Learning. Stay home and Stay Safe 🙂

Permanent link to this article: https://www.sfdcpoint.com/salesforce/workflow-in-salesforce/

1 comment

    • Palak Arora on December 15, 2021 at 4:20 pm
    • Reply

    Hello there!
    Learned alot from your blogs on Salesforce but this time just to draw your attention on the Note about Time-Dependent Action “The evaluation criteria is set to Evaluate the rule when a record is: created, and any time it’s edited to subsequently meet criteria.”
    This is wrong, I think the correct condition is when we can not add time trigger action is “Created, and every time it’s edited”
    Please check.

Leave a Reply

Your email address will not be published.