Which variable to use in an assignment step
When updating records in a Salesforce flow, especially non-record-triggered ones, it's better to use a new clean record variable rather than updating the record variable retrieved from a Get step. This is because updating the original variable updates all fields, including those unchanged, potentially causing inefficiencies. Creating a new record variable with only the necessary fields for update ensures a cleaner and more efficient process.
- Use a new record variable for updates instead of the full retrieved record variable.
- Setting fields on the original Get step variable updates all fields, not just changed ones.
- Creating a minimal record variable with Id and changed fields makes updates cleaner.
- Check flow debug logs to understand which fields are updated.
- This approach improves flow efficiency and reduces unintended data changes.
Imagine a Salesforce flow that is not a record-triggered flow, and you get an Account record. In the get step, you probably use the default setting “Automatically store all fields”, which is good. Let Salesforce work for you. The record variable is called “Get_Account”. Now you want to update the Phone field for this record. Should you update “Get_Account” directly or start with a clean record variable? Let’s first investigate the former approach. Get_Account hold all the account’s fields. If you set Get_Account.Phone = {new value} and then perform an update on Get_Account, all fields are updated – even the ones you don’t set in the flow. You can see this in the flow’s debug log. Now let’s investigate the latter approach. This means creating a new record variable called Account. You set Account.Id = Get_Account.Id and Account.Phone = {new value}. Now when you perform an update on Account, only the phone field is updated.