Table of Contents
- Introduction
- Referral Distribution
- Map default field values when creating Opportunities from Referrals
- Flow Templates to keep Referral and Opportunity in sync
- Update Opportunity from Referral Flow Template
- Update Referral from Opportunity Flow Template
- Update Referral when linking Opportunity Flow Template
- Flow to auto-create Opportunities from an Incoming Referral
- Creating Opportunities automatically
1. Introduction
This article aims to provide information to administrators so that they can configure the flow template in the WorkSpan Salesforce app to create new opportunities from incoming referrals.
2. Referral distribution
The intended process for creating a new opportunity from the incoming referral is the following:
- WorkSpan pushes a new Incoming Referral into Salesforce. This record is created and owned by the Integration User.
- [Optional, if it was set up] Sales Operation Manager (SOM) is notified about a new Incoming Referral. Alternatively, SOM reviews the “Incoming Not Distributed” list view and sees new records.
3. Map default field values when creating Opportunities from Referrals
What happens when a user clicks on the Create Opportunity or Accept & Create button in one of the use cases, is that we launch the “Populate new Opportunity fields from Referral” (PnOffR) Flow in the background. This Flow stores a mapping of field values from a Referral to an Opportunity, extracts those values from the current Referral record and propagates them into a standard “New Opportunity” modal as default values. The user is then free to change any of those values and decide how the Opportunity will look. However, if you have enabled the Flow Templates to keep Referral and Opportunity in sync, then:
- The final field values will be defined in those Flows.
- Any user input and default mappings will be overwritten.
Note: The PnOffR Flow is an Invokable one, meaning it doesn’t work on its own; it needs to be called from another Flow, Process, or code. It is very simple, and the main part is the “Set Opportunity fields” assignment node.
It provides the following mapping:
Source Referral Field |
Target Opportunity Field |
Referral Name |
Opportunity Name |
Close Date |
Close Date |
Sales Stage |
Stage |
Description |
Description |
Next Step |
Next Step |
Note: If you have record types on your Opportunity object, then PnOffR Flow will NOT work unless you extend it to auto-select the record type as described below.
Here’s how you can modify the PnOffR Flow to create Opportunities with specific record type pre-selected, without your users needing to select it manually.
Step 1: Click on the New Resource (1), select Resource Type = ‘Variable’ (2), enter some API Name (3), select Data Type = ‘Text’ (4), and click Done (5).
Step 2: Insert a new “Get Records” node right after the start element.
Step 3: Type in some Label (1), some API Name (2), select Object = ‘Record Type’ (3), Field = ‘DeveloperName’ (4), Value = your desired Opportunity’s Record Type developer name (‘WorkSpan_Opportunity’ in my example) (5), then scroll down.
Step 4: Select Choose fields and assign variables (advanced) (6), In separate variables (7), Field = ‘Id’ (8), Variable = the variable that you created in p.1 (9), and click Done (10).
Step 5: Double-click on the ‘Set Opportunity fields’ assignment node and click Add Assignment.
Step 6: Select Variable = ‘{!Opportunity.RecordTypeId}’ (1), Value = the variable that you created in p.1 (2), and click Done (3).
Step 7: Click Save As (1), enter some Flow Label (2), some API Name (3), a Description to make life easier for yourself and your fellow admins (4), and click Save (5).
Step 8: Click Activate.
Note: The Flow will be saved as a new one, leaving the original PnOffR Flow hanging in the background seemingly useless. However, you should NOT deactivate that original Flow, because the package relies on it to find your new one.
Step 9: Now, your users will also have this Record Type already selected (without the ability to change it) whenever they use the Create Opportunity feature.
You can invoke this same Flow in other use cases. For example, you can:
- Invoke the Flow on the ‘create Referral’ trigger to auto-create an Opportunity as soon as new Incoming Referral land in Salesforce.
- Invoke the Flow on the ‘update Referral’ trigger to auto-create an Opportunity after an Incoming Referral is accepted.
4. Flow Templates to keep Referral and Opportunity in sync
These are Flow Templates to update Referral(s) when the parent Opportunity changes or to update the Opportunity when its child Referral changes—all to keep data between records in sync.
Note: Beware that field updates that span multiple records are all run in a single context, and are also all rolled back in the same context if an error occurs anywhere along the way. For example, let’s say you are utilizing the AWS use cases (see 3.3.1) and have activated the Update Referral from Opportunity Flow Template. Then on an Opportunity that has a Referral for the Amazon partner, you set Stage to ‘Closed Lost’ and click Save. This will result in a validation error being thrown (because there is a validation rule on Referral that prevents Sales Stage from being ‘Closed Lost’ if Closed Lost Reason is blank). Not only the Referral will not be updated, but also the Opportunity will not save until you either populate the Closed Lost Reason field on Referral, disable the validation rule (which will result in bad data being sent to AWS), disable the Flow Template, or extend the Flow Template to bypass or accommodate the validation rule.
4.1. Update Opportunity from Referral Flow Template
This flow updates the Next Step field on the Opportunity whenever it changes on its child Referral. Extend it if you want more Referral field updates to be synced up to the Opportunity level.
Note: Beware that there is no way to define race conditions in Flows, so if multiple Referrals are changed to have a different value in the same field under the same Opportunity at the same time, there is no way to define which value will end up in the Opportunity field. If you also have the Update Referral from Opportunity Flow Template active, this final Opportunity value will be propagated down to all Referrals right away.
4.2. Update Referral from Opportunity Flow Template
This flow updates the Close Date and Sales Stage fields on all Referrals (which are NOT Declined) whenever the Close Date or Stage changes on their parent Opportunity. Extend it (and maybe the Update Referral when linking Opportunity Flow Template) if you want more Opportunity field updates to be synced down to the Referral level.
Note: If you are going to activate this Flow Template or a version of it, and if you are utilizing the AWS use cases (see 3.3.1), then you absolutely have to extend it to accommodate the ClosedLostReasonRequired validation rule (see 2.15.1) on Referral. Here is an example (see 2.10.2) of how it can be achieved.
4.3. Update Referral when linking Opportunity Flow Template
This flow updates the Close Date and Sales Stage fields on one Referral to match Close Date and Stage values from its parent Opportunity whenever this Referral is linked (or re-linked, which you shouldn’t really be doing) to this Opportunity.
Note: This creates an unintentional side effect if you have both this Flow Template as active and a default value mapped for a field.
1. Let’s say an AE has an Incoming Referral with Closed Date = 12/12/2030, and they want to link it to an Opportunity with Closed Date = 1/1/2022. So they select the Opportunity, and click the Link button.
2. If the default Field Mapping is intact, then in the opened Edit Referral modal AE will see the Closed Date change to 1/1/2022 (because it’s pulled from the Opportunity). If the default Field Mapping is removed, then AE will see Closed Date = 12/12/2030 and skip right to step 4.
3. Let’s say AE changes Closed Date back to 12/12/2030.
4. AE clicks Save.
5. After the page refreshes, AE will see that the Closed Date is 1/1/2022.
It happens because the Flow update runs last, and it pushes the value from Opportunity to Referral again after the manual change. This means that you can’t have a discrepancy in the synced fields between Opportunity and Referral. This is the business goal of having this Flow in the first place, so that’s good. Unfortunately, the AE is not informed that there is no point in editing the fields that are kept in sync by the Flow, because, in the end, the Opportunity’s value will always prevail.
But Field Mapping is not applied when you create a new Opportunity. It’s also not possible to fit this use case under the Update Referral from Opportunity Flow Template because it has a different entry trigger—that’s why a separate Flow Template is required.
Extend this Flow Template (and also maybe the Update Referral from Opportunity Flow Template) if you want more Opportunity field updates to be synced down to the Referral level when creating Opportunity from Referral.
Note: If you are going to activate this Flow Template or a version of it, and if you are utilizing the AWS use cases (see 3.3.1), then you absolutely have to extend it to accommodate the ClosedLostReasonRequired validation rule (see 2.15.1) on Referral. Here is an example of how it can be achieved.
5. Flow to auto-create Opportunities from an Incoming Referral
Step 1: On the Flow Setup page, click “New Flow”.
Step 2: Select “Record-Triggered Flow” from the options and click “Create”.
Step 3: Now, you should Set Entry Conditions and click “Done” as shown below:
Note: You can add specific Conditions based on your requirements. Here, we have selected Condition Requirements as “All Conditions are Met (AND)”.
Step 4: Click on the “+” icon and select “Subflow” to invoke the package flow to auto-populate opportunity fields from an incoming referral.
Step 5: Enter the field values as shown below and click “Done”.
Note: It is recommended to add “Label”, “Description” etc. as detailed as possible for better understanding.
Step 6: You can create Opportunities from Referrals by adding a new element “Create Records” from the dropdown menu and entering the fields as shown below.
Once you have entered all the fields, click “Done”.
Step 7: Now, you should Link the original Referral to Opportunity as shown below:
Step 8: Save the flow after entering the required fields.
6. Creating Opportunities automatically
Step 1: Once the flow template is configured, click on "Activate".
Step 2: The referrals are created automatically once the flow template is activated.
Step 3: Whenever a new incoming referral is created within the application, it creates a new opportunity and links it to that referral automatically.
Step 4: Click on the Opportunity to go to its detailed page. You will be redirected as follows:
The opportunity is populated with the mandatory referral values that were required to create the opportunity as configured in the flow template.
Comments
Please sign in to leave a comment.