Add an Action to Update the Opportunity

Update the Opportunity with the Discount and Finish the Flow

Once the flow has determined which discount to apply, it needs to return that information back to the opportunity so that the sales rep knows how much of a discount to offer the customer. Let’s update the opportunity with the value of the discount variable by using an Update Records element.

In an Update Records element, the flow takes two actions. First, it looks up one or more Salesforce records by using criteria. Second, it updates one or more of the record’s fields. The Update Records element updates every record that meets the criteria.

Here, the flow finds an opportunity record whose ID matches the flow variable {!OpportunityId} . Remember, that’s where you stored the ID of the opportunity that triggered the flow. Because IDs are unique, the flow only updates one opportunity. Then it sets the opportunity’s Discount Percentage field to the value of {!Discount} .

  1. From the Elements tab, click and drag an Update Records element onto the canvas.
  2. For Label, enter Update Discount Field.
  3. For How to Find Records to Update and Set Their Values, select Specify conditions to identify records, and set fields individually.
  4. For Update Records of This Object Type, select Opportunity. The Update Records element’s search is limited to Opportunity records.
  5. For Condition Requirements, select All Conditions Are Met (AND).
  6. In Filter Opportunity Records, configure the filter criteria to find the opportunity that triggered the flow.
    Field Value
    Field Id
    Operator Equals
    Value {!OpportunityId}
  7. In Set Field Values for the Opportunity Records, configure the element to update the Discount Percentage field in the opportunity with the value stored in the flow variable {!Discount}.
    Field Value
    Field Discount_Percentage__c
    Value {!Discount}
    A view of the Update Record overlay with the update criteria set
  8. Click Done.
  9. Connect all three Assignment elements to the Update Records element so that the opportunity is updated no matter which outcome was executed.
  10. Save the flow. You should see a grand total of zero warnings this time.
Here’s what your finished flow should look like.
A view of the Flow Builder canvas with a finished flow