Create and Update Element Considerations

When working with Salesforce flows, certain elements require extra attention, especially when performing data manipulation. The Create and Update elements in Salesforce flow are responsible for writing data to the Salesforce database, which is a critical task that requires careful handling to avoid unintended consequences. This post will explore the importance of these elements, how to manage DML (Data Manipulation Language) operations effectively, and best practices to avoid common pitfalls that may lead to errors or performance issues.

SurveyVista: Effortless Data Collection to Action

Importance of Care with DML Operations

Create, update and delete elements need to be handled very carefully. There are several reasons:

  • When you write data to the database, the changes are often irreversible, you may be doing a destructive change that you did not intend to do.
  • Salesforce governors limits are very strict about the number of DML operations you can perform. Especially combined with loops, you may hit limits in your transactions, which means you will experience faults/errors.

Methods of Creating or Updating Records

There are several ways of creating or updating records. You can create/update records one by one or in a collection. When creating/updating records one by one, you need to specify the object type you are working with, and you can set the field values one by one or use a record variable to set all field values in one shot.

Important Tips for RecordId(s)

One important tip here is related to the recordId(s):

  • Your create element does not accept a recordId as input. It will give you a recordId as output, and this will belong to the newly created record.
  • When you create a record using a record variable, or multiple records using a collection record variable, the recordId field must be empty. If you have any recordId value assigned to any record variables, your create element will fail.
  • When you update records using record variables or collection record variables, your recordId fields must have a valid Id value.
  • When you update records to set field values manually, you don’t always have to specify a recordId; you can use filter criteria to determine one or more records that will be updated instead.

Handling Errors

You can use fault lines to catch any errors you may experience when executing these elements. In addition, you can use your debug log, fault email, or failed flow interviews screen to review the debug logs and to view the failed interviews on flow canvas. This view shows the path your failed flow interview took highlighted on canvas.

When you use a fault path while processing a collection, the create/update/delete operation could fail on some records only. This will result in a partial save and commit. For example, 3 records could succeed while 2 records fail, when you attempt to create records using a collection of 5 records.

Free Mentorship With Talent Stacker

Conclusion

The Create and Update elements are powerful tools within Salesforce flows, but they also come with significant responsibility. By understanding the importance of careful handling when performing DML operations and following best practices, you can avoid errors, stay within governor limits, and ensure your flows run efficiently. Remember to always test your flows thoroughly, handle errors gracefully, and use tools like debug logs to catch and resolve any issues quickly. This will help you build robust, reliable flows that can scale with your organization’s needs.

Enjoy

Explore related content:

Top 9 Salesforce Winter 25 Flow Features

6 Things You Can Do With The Transform Element

How to Use the Action Button Component in Screen Flow

Andy Engin Utkan

Andy Engin Utkan is a Salesforce MVP with 24 certifications. He is the founder of Salesforce Consulting Partner BRDPro Consulting. Utkan is a consultant, trainer, and content creator, focusing on automating business processes using Salesforce flow. He is recognized for his expertise in Salesforce flow, providing guidance through various courses and contributing actively to the Salesforce community.
Back to top button

Discover more from Salesforce Break

Subscribe now to keep reading and get access to the full archive.

Continue reading