Salesforce Flow Game Changer For Salesforce Admins and Developers

Salesforce Flow Game Changer For Salesforce Admins and Developers

Last Updated on February 10, 2022 by Rakesh Gupta

Big Idea or Enduring Question:

Many of us are unaware of the power of Salesforce Flow (aka Lightning Flow). It allows you to minimize the code used in your organization by using flow. It’s a tool whereby drag and drop you can build an awesome screen without writing a single line of code. You can even insert, update, Delete a record in Salesforce, all you can do without writing code even Salesforce administrator can use flow very easily.

Business Use Case

Warren Mason, Gurukul on Cloud (GoC) awesome System Administrator, received the following requirement – business wants to update remaining opportunities to Closed lost except for the one whose stage is just updated to Closed won for the same account.

Automation Champion Approach (I-do):

While this can be solved using various automation tools like Apex, etc, we will use Screen Flow

Before proceeding ahead, you have to understand how account and opportunity are connected. If an opportunity has AccountId populated means, it is connected to an account.

Before discussing the solution, let me show you a diagram of a Process Flow at a high level. Please spend a few minutes to go through the following Flow diagram and understand it. Let’s begin building this automation process.

Guided Practice (We-do):

There are 2 steps to solve Corey’s business requirement using After-save Record-Triggered Flow. We must:

  1. Define flow properties for record-triggered flow
  2. Add an update records element to update related opportunity from the same account to lost 

Step 1: Salesforce Flow – Define Flow Properties 

As we have a requirement to update the child records (opportunities) of the parent account when an opportunity marked as closed-won. This is why we have to use the After-save flow on FeedItem.

  1. Click Setup.
  2. In the Quick Find box, type Flows.
  3. Select Flows then click on the New Flow.
  4. Select the Record-Triggered Flow option and click on Next and configure the flow as follows: 
    1. How do you want to start building: Freeform
    2. Trigger the Flow When: A record is created or Updated
    3. Run Flow: After the record is saved
    4. Object: Opportunity 
  5. Select Any Condition Are Met (OR)
  6. Set Conditions
    1. Row 1
      1. Field: StageName
      2. Operator: Equals
      3. Value: Closed Won
    2. Click Add Condition
    3. Row 2
      1. Field: AccountId
      2. Operator: Is Null
      3. Value: {!$GlobalConstant.False}
  7. Click Done.

Step 2: Lightning Flow – Update Records – Update Opportunities from the Same Account to Closed Lost 

The next step is to update the opportunities from the same account to closed lost. For this, we will use an Update Record element.

  1. Under Toolbox, select Element
  2. Drag-and-drop Update Records element onto the Flow designer. 
  3. Enter a name in the Label field; the API Name will auto-populate.
  4. Click Specify conditions to identify records, and set fields individually
  5. Object: Opportunity
  6. Select All Conditions Are Met (AND)
  7. Set Filter Conditions
    1. Row 1:
      1. Field: IsClosed
      2. Operator: Equals
      3. Value: {!$GlobalConstant.False}
    2. Click Add Condition
    3. Row 2
      1. Field: Id
      2. Operator: Does Not Equal
      3. Value: {!$Record.Id}
    4. Click Add Condition
    5. Row 3
      1. Field: AccountId
      2. Operator: Does Not Equal
      3. Value: {!$Record.AccountId}
  8. Set Field Values for the Opportunity Records
    1. Row 1:
      1. Field: StageName
      2. Value: Closed Lost
  9. Click Done.

In the end, Warren’s Flow will look like the following screenshot:


Once everything looks good, perform the steps below: 

  1. Click Save.
  2. Enter Flow Label the API Name will auto-populate.
  3. Click Show Advanced.
  4. API Version for Running the Flow: 51
  5. Interview Label: Update Related Opportunities to Lost {!$Flow.CurrentDateTime}
  6. Click Save

Proof of Concept

Now onwards, when a business user updates the Opportunity Stage to Closed Won, Salesforce Flow will automatically update the related Opportunities from the same account to Closed Lost.

  1. Currently, there are three Opportunities attached to Opportunity Deutsche Telekom Inc as shown in the following screenshot
  2. Now we update the Stage on Deutsche Telekom Inc – Q2 FY21 to Closed Won.
  3. Navigate back to the Account to confirm other records are changed.

Formative Assessment:

I want to hear from you!  

What did you learn from this post, is it relevant to you, and how will you modify the concepts taught in the post for your own business processes? 

Make a post and tag me on Twitter @automationchampusing #AutomationChampion. 

Have feedback, suggestions for posts, or need more information about Salesforce online training offered by me? Say hello, and leave a message!

25 thoughts on “Salesforce Flow Game Changer For Salesforce Admins and Developers

  1. Hi Rakesh,

    I wonder why u did not use Before Save Update for the above given problem.? We are updating the same object record’ on which we have written our trigger.Is it because we are updating other opp records not the one which has caused the flow to fire.?

  2. I am getting the following error when click the custom button on the Opportunity detail page

    An unhandled fault has occurred in this flow
    An unhandled fault has occurred while processing the flow. Please contact your system administrator for more information.

      1. Is this what you are looking for?

        WF_RULE_INVOCATION; WF_APPROVAL; WF_FIELD_UPDATE; WF_SPOOL_ACTION_BEGIN; WF_ACTION; WF_FORMULA; WF_RULE_EVAL_BEGIN; WF_RULE_EVAL_END; WF_RULE_EVAL_VALUE; WF_CRITERIA_BEGIN; WF_CRITERIA_END; WF_RULE_ENTRY_ORDER; WF_RULE_NOT_EVALUATED; WF_RULE_FILTER; WF_ESCALATION_RULE; WF_ESCALATION_ACTION; WF_TIME_TRIGGERS_BEGIN; WF_TIME_TRIGGER; WF_ACTIONS_END; WF_ENQUEUE_ACTIONS; WF_APPROVAL_SUBMIT; WF_APPROVAL_SUBMITTER; WF_APPROVAL_REMOVE; WF_NEXT_APPROVER; WF_EVAL_ENTRY_CRITERIA; WF_PROCESS_FOUND; WF_SOFT_REJECT; WF_HARD_REJECT; WF_PROCESS_NODE; WF_ASSIGN; WF_REASSIGN_RECORD; WF_RESPONSE_NOTIFY; WF_OUTBOUND_MSG; WF_ACTION_TASK; WF_EMAIL_ALERT; WF_EMAIL_SENT; SLA_PROCESS_CASE; SLA_NULL_START_DATE; SLA_EVAL_MILESTONE; SLA_END; WF_KNOWLEDGE_ACTION; WF_SEND_ACTION; WF_CHATTER_POST; WF_QUICK_CREATE; WF_FLOW_ACTION_BEGIN; WF_FLOW_ACTION_DETAIL; WF_FLOW_ACTION_END; WF_FLOW_ACTION_ERROR; WF_FLOW_ACTION_ERROR_DETAIL; WF_APEX_ACTION; EVENT_SERVICE_PUB_BEGIN; EVENT_SERVICE_PUB_END; EVENT_SERVICE_SUB_BEGIN; EVENT_SERVICE_SUB_END; FLOW_CREATE_INTERVIEW_BEGIN; FLOW_CREATE_INTERVIEW_END; FLOW_CREATE_INTERVIEW_ERROR; FLOW_START_INTERVIEWS_BEGIN; FLOW_START_INTERVIEWS_END; FLOW_START_INTERVIEWS_ERROR; FLOW_START_INTERVIEW_BEGIN; FLOW_START_INTERVIEW_END; FLOW_INTERVIEW_PAUSED; FLOW_INTERVIEW_RESUMED; FLOW_ELEMENT_BEGIN; FLOW_ELEMENT_END; FLOW_ELEMENT_FAULT; FLOW_ELEMENT_DEFERRED; FLOW_ELEMENT_ERROR; FLOW_BULK_ELEMENT_BEGIN; FLOW_BULK_ELEMENT_END; INVOCABLE_ACTION_ERROR;

          1. Error element Update_all_Opportunity_as_Closed_Lost_except_Closed_Won (FlowRecordUpdate).
            The flow tried to update these records: 0061I0000028E0JQAU. This error occurred: ALL_OR_NONE_OPERATION_ROLLED_BACK: . For details, see API Exceptions.—The flow tried to update these records: 0061I000005MixgQAC. This error occurred: ALL_OR_NONE_OPERATION_ROLLED_BACK: . For details, see API Exceptions.—The flow tried to update these records: null. This error occurred: REQUIRED_FIELD_MISSING: Required fields are missing: [Discount_Percent__c]. For details, see API Exceptions.
            This report lists the elements that the flow interview executed. The report is a beta feature.
            We welcome your feedback on IdeaExchange.
            Flow Details
            Flow Name: Charu_s_Fow_for_updating_opportunity_to_Closed_lost
            Type: Flow
            Version: 2
            Status: Active
            Flow Interview Details
            Interview Label: Charu’s Fow for updating opportunity to Closed lost 2/5/2018 9:58 AM
            Current User: Charu Agarwal (0051I000000Q99y)
            Start time: 2/5/2018 9:58 AM
            Duration: 0 seconds
            How the Interview Started
            Charu Agarwal (0051I000000Q99y) started the flow interview.
            RECORD QUERY: Account_id_of_closed_won_opportunity
            Find one Opportunity record where:
            StageName Equals Closed Won
            Result
            Successfully found record.
            {!AccountId} = null
            RECORD UPDATE: Update_all_Opportunity_as_Closed_Lost_except_Closed_Won
            Find all Opportunity records where:
            AccountId Equals {!AccountId} (null)
            StageName Does not equal Closed Won
            Update the records’ field values.
            StageName = Closed Lost
            Result
            Failed to update records that meet the filter criteria.

  3. Amazing Posts Rakesh.

    I am hoping to get some solution on my requirement ,when Account owner is changed,defaultly,Opportunity owner changes too,but it doesn’t trigger Opp owner adding to the Opp team.I have been tried Process builder and Apex coding.but it couldn’t working on it ,is it possible with flows?

    Thanks,
    harish.

  4. Been working on something similar but with no luck I am trying to update a Lead date/time field based on the last completed Task date/time. For some reason, I can not capture the Lead ID with the associated Task.

          1. Figured it out. I neglected to pass the vLeadID from my Process Builder that invokes the Flow action. Sometimes the most simple things that get overlooked cause the biggest headaches…

  5. Hi Rakesh

    Can you please explain how the account Id was populated? I didn’t see that it was passed using the custom button.

    Thanks.

    1. Hi Rakesh,

      I tried the “Visual workflow game changer for Salesforce admin/developer” but did not work as expected.
      dont know what I missed ? did it exactly as instructed. ?

      is there any permissions etc I need to turn on.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.