Soru

Zorluk: ZorOrder of Execution and Automation Considerations

An organization uses a custom object named Equipment_Maintenance__c. An administrator configures the following features on the object:

1. A Before-Save Record-Triggered Flow that calculates and sets the Total_Cost__c field to equal Parts_Cost__c + Labor_Cost__c.
2. A Custom Validation Rule with the formula Total_Cost__c > 5000 that displays an error to prevent saving high-cost maintenance records without manager approval.
3. An After-Save Record-Triggered Flow that creates a follow-up task for the facility manager.
4. A Workflow Rule that sends an email notification to the maintenance supervisor.

A technician updates an existing record, changing Parts_Cost__c to 3,000 and Labor_Cost__c to 3,000 (making the calculated total $6,000), while leaving Total_Cost__c blank on the page layout.

Which statement accurately describes how Salesforce processes this save operation according to the order of execution?

  1. The Before-Save Record-Triggered Flow executes first to set Total_Cost__c to $6,000; then the Custom Validation Rule evaluates the updated Total_Cost__c value and blocks the record from saving.Cevap
  2. B
    The Custom Validation Rule evaluates Total_Cost__c using the blank value first and passes; then the Before-Save Record-Triggered Flow populates Total_Cost__c with $6,000.
  3. C
    The record is saved to the database first; then the Custom Validation Rule and Before-Save Record-Triggered Flow run concurrently before Workflow Rules execute.
  4. D
    The Workflow Rule evaluates Total_Cost__c before the Before-Save Record-Triggered Flow populates the calculated field value.

Cevap

The Before-Save Record-Triggered Flow executes first to set Total_Cost__c to $6,000; then the Custom Validation Rule evaluates the updated Total_Cost__c value and blocks the record from saving.
In the Salesforce Order of Execution, Before-Save Record-Triggered Flows execute very early (step 4), prior to Apex before triggers and custom validation rules (step 6). As a result, the flow calculates and updates the field value to 6,000first.Whenthecustomvalidationruleexecutesnext,itreadstheupdatedvalueof6,000 first. When the custom validation rule executes next, it reads the updated value of 6,000, satisfies the error condition (6,000>6,000 > 5,000), and blocks the save operation.

Adım Adım Çözüm

1
Analyze the incoming request data
Parts_Cost__c is updated to 3,000 and Labor_Cost__c to 3,000.
The system loads the new field values from the user input into the record memory.
2
Evaluate early automation steps in the Salesforce Order of Execution
Before-Save Record-Triggered Flows execute before custom validation rules.
Salesforce order of execution explicitly runs Before-Save Flows at step 4, updating Total_Cost__c to $6,000.
3
Evaluate validation rules
Custom Validation Rules execute at step 6, testing the formula Total_Cost__c > 5000.
Since Total_Cost__c was set to 6,000bytheBeforeSaveFlow,6,000 by the Before-Save Flow, 6,000 > $5,000 evaluates to TRUE, triggering the validation error and stopping the transaction.

Anahtar Kavram

Salesforce Order of Execution relative timing between Before-Save Record-Triggered Flows and Custom Validation Rules.
Tahmini Süre:2m 0s
Bu soruyu puanla