Before save/insert flow example in Salesforce - Convert field to uppercase

Telegram logo Join our Telegram Channel

Like the before-insert trigger, we can also create a before-insert flow to process record data before it is saved to the database. In this post, we will see how to create a before-insert flow in Salesforce with a step-by-step procedure.

Use Case

The requirement is to convert the Product Code entered by the user to uppercase when a new product is created.

Create "before insert" flow step-by-step

  1. Go to setup and search for flow in the quick find.
  2. Click New flow and then select Record-Triggered Flow.
  3. Select the Object (which is Product here) and select the trigger event A record is created like below:
    Create new record trigged flow on Product object
    New Record Trigged flow on Product
  4. Now scroll down further on the same page and in the Set Entry Conditions section select the Fast Field Update option to run the flows before inserting the record. Like below:
    Run flow in before save
    Create record trigged flow with fast field update (before insert)
  5. Additionally, you can select entry conditions for flow, for this example, I am checking if the "Product Code" field is not empty or null.
    Check if product code is not empty
    Add entry condition to flow.
  6. Now that we have entry conditions for the flow it's time to update the fields. Because this is a before-save flow, we don't need to use the "Update Record" action, we just need to set the field values using the "Assignment" action and Salesforce will automatically save the data.

    Remember: It is important to note that we don't use the "Update Record" action in the before-save flow.
  7. Let us create an assignment operation to convert the "Product Code" field into Uppercase. But before that, we need a formula resource to convert the old "Product Code" to upper case because we can't use the formula directly in the Assignment operation.
    Formula - Convert to Uppercase
    Formula - Convert to Uppercase
  8. Let us plug this formula into the assignment operation
    Use formula resource in assignment
    Use the formula resource in the assignment
  9. That's all, "before save" i.e. "before insert" flow is ready, it's time to activate and test the flow. Create a new product record with the "Product Code" value populated, and it should be converted to uppercase.
  10. Once activated properly test flow and migrate to the production org.

When to/not to use before save/fast field update flows?

  • You would typically use "before save" flows in Salesforce when you need to execute actions or validations before a record is saved to the database. On the other hand, "fast field update" flows are employed for efficiently updating fields on multiple records in bulk operations.
  • Don't use flows when you need to update a related record. Additionally, if the logic you need to execute is more appropriate for post-save processing, such as sending emails or triggering subsequent actions, then a "before save" flow would not be suitable.

No comments :
Post a Comment

Hi there, comments on this site are moderated, you might need to wait until your comment is published. Spam and promotions will be deleted. Sorry for the inconvenience but we have moderated the comments for the safety of this website users. If you have any concern, or if you are not able to comment for some reason, email us at