Loading

Count Sent and Received Email Messages in Salesforce Cases

Julkaisupäivä: May 25, 2026
Kuvaus

This article explains how to track the number of inbound and outbound email messages on a Salesforce Case record using Record-Triggered Flows. This is useful for reporting on case email volume and agent response metrics.

 

Ratkaisu

Create Two (2) Fields on Case Object

 

1. Go to:

Salesforce Classic: Setup | Customize | Cases | Fields
Lightning Experience: Gear icon | Setup | Object Manager | Case | Fields & Relationships

2. Click New
3. Choose Number as the Data Type
4. Input Field Label for the two fields below
 
  • Number of Messages Sent - This will store the number of emails sent on a particular Case.
  • Number of Messages Received - This will store the number of emails received on a particular Case.

5. Input 18 on the Length field.
6. Input on the Decimal Places field.
7. Field Name will be automatically populated once you enter a Field Label.
8. Click Next.
9. Tick the checkbox for Visible for all profiles.
10. Tick the checkbox for all the page layouts available.
11. Click Save.

 

Create Separate Flows For The Two Fields

 

For an Email Message Sent From the Case Record:

1. Salesforce Classic:  Setup | Create | Workflow & Approvals | Flows | Continue | New Flow
    Lightning Experience:  Setup | Process Automation | Flows | Continue | New Flow

2. Click on New Flow Start From Scratch

3. Select TypeRecord Triggered Flow

4. Configure StartChoose Email Message as Object
→ Trigger the Flow When
: A record is created or updated
→ Set Entry Conditions: Email Message Status - EQUALS - Sent
Optimize the Flow for: Actions and Related Records

5. Click on Add element (+ icon )

6. Select Update Records element

7. Configure the Update Records element:
→ Fill out the Label and Description as per your requirement
How to Find Records to Update and Set Their Values: Update records related to the email message record that triggered the Flow
→ Select Related Records: Triggering Email Message > Case ID ( which should Look Like {!$Record.Parent})
Set Filter Conditions: NONE
Set field values for the case records: Select the custom field you have created (Case: Number of Messages Sent), and in the Value section, select New Resource.

8. Select Resource Type as Formula
→ Fill in the API name and Description
→ Select Data Type as Number
→ Use this formula:
IF(ISBLANK({!$Record.Parent.Number_of_Messages_Sent__c}),1,$Record.Parent.Number_of_Messages_Sent__c+1)
→ Click on Done

9. Select the Formula as the Value

10. Save the Flow and Activate it

     

    For an Email Message Received (Reply from Customer):

     

    1. Salesforce Classic:  Setup | Create | Workflow & Approvals | Flows | Continue | New Flow
        Lightning Experience:  Setup | Process Automation | Flows | Continue | New Flow

    2. Click on New Flow → Start From Scratch
     
    3. Select Type → Record Triggered Flow
     
    4. Configure Start → Choose Email Message as Object
    → Trigger the Flow When:
    A record is created or updated
    → Set Entry Conditions: Custom Condition Logic is met
        Email Message: Is Incoming - EQUALS - True AND Email Message: Status - EQUALS - New
    → Add Condition Logic as 1 AND 2
    Optimize the Flow for: Actions and Related Records

    5. Click on Add element (+ icon )
     
    6. Select Update Records element

    7. Configure the Update Records element:
    → Enter Label and Description as per your requirement
    → How to Find Records to Update and set the values: 
    Update records related to the email message record that triggered the flow
    → Select Related Records: Triggering Email Message > Case ID ( which should Look Like {!$Record.Parent})
    → Set Filter Conditions: NONE
    → Set field values for the case records:- Select the custom field you have created (
    Case: Number of Messages Received) , and in the Value Section, select New Resource.

    8. Select the Resource Type as Formula
    → Fill in the API name and Description
    → Select Data Type as Number
    → Use this formula:
    IF(ISBLANK({!$Record.Parent.Number_of_Messages_Received__c}),1,$Record.Parent.Number_of_Messages_Received__c+1)

    → Click on Done

    9. Select the Formula as type Value
     
    10. Save the Flow and Activate it
     
    Knowledge-artikkelin numero

    000386661

     
    Ladataan
    Salesforce Help | Article