Auto Revenue Splitting in Opportunities

Auto Revenue Splitting in Opportunities

Last Updated on February 10, 2022 by Rakesh Gupta

Big Idea or Enduring Question:

How do you automatically split revenue using Salesforce Flow?

In a recent email conversation with a Community member, we discussed the possibility of auto Split Opportunity revenue with Opportunity Team Members. When a new member is added to the Opportunity Team by clicking on the Add Opportunity Team Members (1) button and not for Add Default Team (2), as shown in the following screenshot: 

Objectives:

After reading this blog, you’ll be able to: 

  • Understand the basic building blocks of Salesforce Flow
  • Learn how to split the opportunity revenue using Salesforce Flow

Business Use case

Martin Jones is working as a System Administrator at Universal Containers (UC). He has received a requirement from higher management to auto-share 1% of Opportunity revenue with, Opportunity team members as soon as a new member is added to the Opportunity team. Same time they don’t want to implement this feature when a user uses the Add Default Team button to add a default Opportunity team to an Opportunity.

Automation Champion Approach (I-do):

Multiple approaches can be taken to solve this business requirement. Either a process builder or Flow and Inline Visualforce Page or other approaches can be taken.

To solve this requirement, we will use the After-save Record-Triggered Flow. Check out this article to understand why we are using after-save record-triggered flow for this scenario.

Before proceeding, ahead, understanding the below-listed Salesforce objects: 

Object Details
OpportunityTeamMember Represents a User on the opportunity team of an Opportunity.
OpportunitySplit Credits one or more opportunity team members with a portion of the opportunity amount.
OpportunitySplitType Provides unique labels and behavior for each split type.

Before discussing it, let me show you a diagram of a Process Flow at a high level. Please spend a few minutes going through the following Flow diagram and understand it.

Team Selling should be enabled in the org. If it isn’t yet enabled,  and want to do so, then please have a look at the Splitting Credit across Your Sales Team article.

Let’s begin building this automation process.

Guided Practice (We-do):

There are 3 steps to solve Martin’s business requirement using Salesforce Flow. We must:

  1. Find Opportunity Split Type Revenue Id
  2. Creating a custom label to store Opportunity Split Type Revenue Id
  3. Salesforce Flow
    1. Define Flow properties for record-triggered flow
    2. Create a Formula to determine whether the account record is created or updated
    3. Add a Decision element to check if the IsNew formula returns True or False
    4. Add a Create Records element to create an opportunity split type record

Step 1: Find Opportunity Split Type Revenue Id

The first step is to find out the Id of Opportunity split type Revenue. One possible workaround is to use the Developer Console. 

  1. Click Setup | Developer Console 
  2. In the Query Editor, run the following SOQL query 
    1. Select id,MasterLabel from opportunitySplitType
  3. Make sure to Copy Revenue Id. 

Step 2: Creating a Custom Label to Store Opportunity Split Type Revenue Id

  1. Click Setup.
  2. In the User Interface, type Custom Labels.
  3. Click on the New Custom Label button.
  4. Enter Short Description the Name will auto-populate. 
  5. Now enter the Opportunity Split Type Revenue Id in the Value.
  6. Click Save.

Step 3.1: Salesforce Flow – Define Flow Properties

  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 Create and configure the flow as follows:
    1. Object: Opportunity Team Member
    2. Trigger the Flow When: A record is created or updated
    3. Set Entry Criteria
      1. Condition Requirements: None
    4. Optimize the Flow For Action and Related Records
  5. Click Done.

Step 3.2: Salesforce Flow – Formula to Determine Whether the Account Record is Created or Updated

  1. Under Toolbox, select Manager, then click New Resource to determine whether the record is new or old.
  2. Input the following information:
    1. Resource Type: Formula
    2. API Name: forB_IsNew
    3. Data Type: Boolean
    4. Formula: IsNew()
  3. Click Done.

Step 3.3: Salesforce Flow – Using Decision Element to Check the IsNew Formula Outcomes

Now we will use the Decision element to check if the IsNew formula returns True or False.

  1. On Flow Designer, click on the + icon and select the Decision element.
  2. Enter a name in the Label field; the API Name will auto-populate.
  3. Under Outcome Details, enter the Label the API Name will auto-populate.
  4. Condition Requirements to Execute Outcome: All Conditions Are Met (AND)
    1. Row 1:
      1. Resource: {!forB_IsNew}
      2. Operator: Equals
      3. Value: {!$GlobalConstant.True}

Step 3.4: Add Action – Create a Record Element to Create an Opportunity Split Type Record

The next step is to create a record Opportunity Split Type object. For this, we will use the Create Records element. Now follow the steps below:

  1. On Flow Designer, click on the + icon and select Created Records element.
  2. Input the following information:
    1. Enter Label the API Name will auto-populate.
    2. How Many Records to Create: One
    3. How to Set the Record Fields: Use separate resources, and literal values
    4. Object: Opportunity Split
    5. Set Field Values for the Opportunity Split
      1. Row 1:
        1. Field: OpportunityId
        2. Value: {!$Record.OpportunityId}
      2. Click Add Row
      3. Row 2:
        1. Field: SplitOwnerId
        2. Value: {!$Record.UserId}
      4. Click Add Row
      5. Row 3:
        1. Field: SplitOwnerId
        2. Value: 1 
      6. Click Add Row
      7. Row 4:
        1. Field: SplitTypeId
        2. Value: $Label.opportunity_split_type_revenue_id
  3. Click Save.


In the end, Martin’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: 54
  5. Interview Label: Record-Trigger: Record-Triggered Flow: Opportunity Team Member {!$Flow.CurrentDateTime}
  6. Click Save.

Almost there! Once everything looks good, click the Activate.

Proof of Concept

Now onwards, if business users add new members in Opportunity Team by clicking on the Add button (Available under Opportunity Team related list on the Opportunity Detail page), then Salesforce Flow will automatically Share 1% of Opportunity revenue with them.

  1. Right now, there is only Opportunity Owner and no team members in Opportunity Team for Opportunity Burlington Textiles Weaving Plant Generator, as shown in the following screenshot:
    1. Below is the current status of Opportunity Splits.
  2. Now we will try to add a new team member in Opportunity – Burlington Textiles Weaving Plant Generator by clicking on Add Opportunity Team members button, as shown in the following screenshot:
    1. It will redirect you to the page from where you can add new members to an Opportunity, as shown in the following screenshot:
  3. Once you are done, click on the Save button and navigate to the Opportunity Splits related list available on the Opportunity Detail page. 1% of Opportunity revenue is automatically shared with new Team members by Salesforce Flow, as shown in the following screenshot:

Formative Assessment:

I want to hear from you!  

What is one thing you learned from this post? How do you envision applying this new knowledge in the real world? 

Let me know by Tweeting me at @automationchamp, or find me on LinkedIn.

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

 

7 thoughts on “Auto Revenue Splitting in Opportunities

  1. Hello. I agree, this is very helpful information. I am running into an error, however, where the system is preventing the Opportunity Split record from being created because the Revenue splits must equal 100%. I was wondering how this design would address this challenge and when I just tested it I am still receiving this error. Please let me know if I missed a step in the process but I don’t believe I did. Thank you for your time!

  2. This was really very helpful. However I added two criteria and the process doesn’t work. Maybe you can help me? The first criteria I added is that the opportunity needs to have a specific record type. That is working fine. But in the same criteria I added a second rule saying: Opportunity Owner Role contains “development”. I have a formula field on the opportunity that shows me the owner role. This is the field I’m referring to. The process doesn’t work and I am wondering if it is due to the field or due to “contains the word development”. Any experience with such a case? Thanks a lot!

Leave a Reply

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