Workflow Rule in Salesforce



Workflow Rule in Salesforce:  

Workflow rules is an automation tool in Salesforce that offers time-saving solutions for making different internal processes of a company switch from manual work and for optimizing various procedures.

Workflow in Salesforce is basically a container or business logic engine which automates certain actions based on particular criteria. If the criteria are met, the actions get executed. When they are not met, records will get saved but no action will get executed.

Components of Workflow in Salesforce:

Workflow rules in Salesforce can be broken down into two main components:

  1. Criteria:
    Criteria are conditions you are supposed to put in order to test a record. For example, if you’re from a technical background, what the if statement does in an if/then the condition is what criteria mean in a workflow.

  2. Actions:
    Actions occur after a record meets the criteria. Again, what the then statement does in the if/then the condition is what an action means in the workflow.

Types of actions present in a workflow in Salesforce:

  • Immediate actions:
    Actions that get executed immediately when a record is created or edited

  • Time-dependent actions:
    Actions that get executed after a certain duration of time.

Types of evaluation criteria:

  • Created:
    Whenever a record is created and the criteria match with the record, the action is executed.

  • Created and edited it:
    Whenever a record is created or updated, the action will be executed.

  • Created and every time it’s edited to subsequently meet the criteria:
    Whenever a record is created and it stands true to the criteria, the action will be performed. Now, if the record is edited and it doesn’t meet the criteria, the action will not be performed.

    Suppose, the created record doesn’t meet the criteria, and then it is edited or updated to meet the criteria. It will be evaluated again and, if it meets the criteria, the action will be performed. Otherwise, it won’t be performed.

Types of Workflow actions:

  1. Task – Assign a Task.
  2. Email Alert – Send an Email.
  3. Field update – Update a Field.
  4. Outbound message – Send an Outbound message.

Workflow Limits:

PER-ORG LIMITVALUE

Total rules across objects

(Applies to any combination of workflow, assignment, auto-response, and escalation rules, active and inactive.)

2,000

Total rules per object

(Applies to any combination of workflow, assignment, auto-response, and escalation rules, active and inactive.)

500

Active rules per object

(Applies to any combination of active workflow, assignment, auto-response, and escalation rules, as well as record change processes.)

50
Time triggers per workflow rule110
Immediate actions per workflow rule140
Time-dependent actions per time trigger40
Workflow time triggers per hour1,000
Flow trigger workflow actions: flow variable assignments225 (N/A in Professional Edition)

Combined total of these automations that start or resume based on a record’s field value.

  • Resume events that are defined in active flows
  • Groups of scheduled actions that are defined in active processes
  • Time triggers that are defined in active workflow rules
  • Inactive flow interviews that are resumed
20,000

The immediate actions and each time trigger can have:

  • 10 email alerts
  • 10 tasks
  • 10 field updates
  • 10 outbound messages
  • 10 flow triggers


# How can we count the total number of workflow rules in our org.

Counting one by one manually is a time consuming process if there are more rules! Solution is using a simple SOQL query we can get the total workflow count. 

  • Go to Salesforce org
  • Click on Gear Icon (Dropdown menu)
  • Click on Developer Console
  • In the Developer Console, click the Query Editor  tab.
  • Copy and paste the following SOQL Code line into the first box under Query Editor, and then click Execute.

1. To get the overall workflow rule count in the org, use

SELECT count(Id), TableEnumOrId FROM WorkflowRule Group by TableEnumOrId

2. To get the workflow rule count for any sObject. Let's say for account object use

SELECT count(Id), TableEnumOrId FROM WorkflowRule WHERE TableEnumOrId = 'account' Group by TableEnumOrId

## Don't forget to check the 'Use Tooling API' checkbox next to Execute.

Note: 

By default, each object is limited to 50 active workflow rules. Total workflow rules per object is 500.


 Resources: 


Comments

Popular Posts

Asynchronous Apex in Salesforce : Future Methods

Salesforce Admin Interview Questions and Answers

Apex Triggers in Salesforce

DML - Data Manipulation Language in Apex