Flow

Update or Assignment Element in Before Save Record-Triggered Salesforce Flows?

You can now use update elements in Record-Triggered flows to update the field values that triggered the flow regardless of whether that flow is set to run before-save or after-save.

Before Summer ’21, you had to use the assignment element to update these field values in a before-save situation. And this was very confusing for new flow developers learning record-triggered flows.

Here is how you would do your flow before Summer ’21:

Your assignment element would look like this:

After Summer ’21 you can use an update element. You can still use an assignment element, as well, if that is what you prefer. Your flow will look like this (same for both before and after save flow):

I recommend using the update element for all record-triggered flows. If you need to change your flow from before-save to after-save at some point, you can easily do that.

Enjoy.

7 thoughts on “Update or Assignment Element in Before Save Record-Triggered Salesforce Flows?”

  1. If you would have an after save flow with multiple outcome orders in a decision element. Let’s say 3 of them. And you need to create a new record. Would you then use 3 times a create record element (for every outcome) ? or would you use 3 assignment elements that will all connect to 1 create record element?

    Like

    1. I personally prefer formula + assignment is that’s possible. However from a performance standpoint, I don’t think it matters because you won’t ever do more than one create in any run even if you have let’s say three create elements. Your decision criteria should be mutually exclusive to ensure that. Great question. Thanks.

      Like

  2. Hi Engin, Thanks so much for this post! I noticed the change, and hadn’t seen any information about it from Salesforce, so I was confused.

    I had a follow-up question. There are times when I have several decision elements in an After Save flow, and so will need to possibly update several fields on the same record. Would it be more performant to use Assignment elements tied to each node, and do an Update Record at the end, or is it OK to use multiple Update Records elements?

    I wasn’t sure if there was intelligence in the flow engine to only update the one record once, or if it actually performed multiple updates. Thanks for your advice.

    Like

    1. When we are working in an after-save flow your update element is a DML operation. From a performance and governor limit standpoint, it makes sense to do less updates. However, if you don’t have a flow that’s not very big and you have update elements behind mutually exclusive decision outcome conditions, I don’t think it matters. In other words, if you have 5 update elements in your flow, and in any scenario you have one or two executing you should be fine. In a before-save flow, the update element is an assignment element under the hood. So you can be less careful, it will not carry out a DML operation. I hope this answers your question.

      Like

    2. I think assignment impact is negligable. And if you are only going down one of the update paths in one unique run you should be fine with multiple updates. If your flow is getting really big then one update is better I think.

      Like

    1. There cannot be a performance difference in before-save flows because a DML update is technically not possible. The update element in before-save is a mere shortcut to an assignment under the hood. Same thing.

      Like

Leave a Reply