8

I thought I knew this stuff but in Triggers and Order of Execution Step 2

  1. Loads the new record field values from the request and overwrites the old values.

If the request came from a standard UI edit page, Salesforce runs system validation to check the record for:

  • Compliance with layout-specific rules

  • Required values at the layout level and field-definition level

  • Valid field formats

  • Maximum field length

When the request comes from other sources, such as an Apex application or a SOAP API call, Salesforce validates only the foreign keys. Before executing a trigger, Salesforce verifies that any custom foreign keys do not refer to the object itself.

Based on my tests (FldOfLen10__c, Account.Name, Contact.Email)

  • From execute anonymous
  • From workbench REST POST (I did not try SOAP)

Salesforce validates field lengths, required fields, and field formats BEFORE the triggers execute.

I can appreciate how Salesforce needs to reverify these at the conclusion of the before trigger (Step 4).

I looked back at the doc all the way to V30.0 and the same language is present for Step 2.

Is this a doc bug or where am I wrong?

1
  • I tested it as well, and can confirm that system validations run prior to Before Triggers in Exec Anon and in Async context (@future), not allowing you to fix bad input programmatically. Tested with API v50, Field - Account Name being too long. Jan 22 at 14:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.