Record Trigger Flow Scenario
Scenario: When the “Type” field of an Account is updated, you want to update the Opportunity “Type” field for all related Opportunities. Additionally, you want to apply different logic to update the “Opportunity Type” field for each Opportunity based on specific conditions.
Specific Conditions for Updating “Opportunity Type” Field:
The specific conditions for updating the “Opportunity Type” field for each Opportunity are as follows:
-
- If the Opportunity’s “Stage” is “Prospecting” and the Account’s “Type” is “Customer Direct,” set “Opportunity Type” to “Existing Customer – Upgrade.”
- If the Opportunity’s “Stage” is “Qualification” and the Account’s “Customer-Channel” set “Opportunity Type” to ” Existing Customer – Replacement.”
Answer
1.Understand the Requirement:
Trigger Point: When Account field ‘Type’ is updated.
Output: Set Opportunity field ‘Type’ based on specific conditions
2. Visualize the Flow:
Sequence:
- Record Triggered Flow – It will be Record Trigger Flow on Account as triggering point is account.
- Trigger the Flow When – When Account is Updated
- Set Entry Conditions – Don’t give entry conditions so that flow can be reused for other conditions. We can add decision element for different conditions
- Action and Related Records – Based on Account we need to make changes to Opportunity field. Which means Based on A Object do Changes to B object. In these scenarios we use action and related records.
3. Decision: Use Decision element to check Account Type field – Customer Direct and Customer Channel
Below will be the output once you click on Done.
Update Records: If the Opportunity’s “Stage” is “Prospecting” and the Account’s “Type” is “Customer Direct,” set “Opportunity Type” to “Existing Customer – Upgrade.”
We will select Update Record Element for Each Decision.
Update Records: If the Opportunity’s “Stage” is “Qualification” and the Account’s “Customer-Channel” set “Opportunity Type” to ” Existing Customer – Replacement.”
Once You click done it will look like below
Debug The Flow: Let’s put account type field as customer channel while debugging the flow.
Click on Debug Button on top right corner
Click Run
How the Interview Started – It gives detail about user who ran the flow, Api version, Account Id, Flow Start Time
There are no entry criteria, so it shows null
Decision: It went inside Decision Element – Account Type equals Customer- Channel and skipped Account Type equals Customer – Direct
It finds all Opportunities where Stage Name Equals Qualification and Update Opportunity Type field equals Existing Customer – Replacement
You can see the dark blue line showing the debug Track going to decision element customer channel and updating opportunities accordingly.
Now let’s check on the record level.
Open an existing Account as flow is triggered when Account is updated and change type to Customer – Channel and click Save.
Opportunity having stage as Qualification will change type to Existing Customer Replacement
Now that our use case has passed successfully let’s write Flow Test. Select ‘View Test’ Button on top right corner.
Click on Create
Setup Test Details: On this screen we mainly have to put label name. Updated is automatically selected in our use case.
Set initial Triggering Records: It means when record is created field values at that time
Set Updated Triggering Records: This means record values when the account record is updated. Here we are putting type as Customer – Channel
Set Assertions: Here we are saying that Update Element was visited by the flow – which contains when stage name equals Qualification, update Opportunity type equals Existing Customer Replacement . I am setting it true Because once we update Account type to customer channel then that Update Element should be visited by the flow.
Click on Done -> View Test -> then ‘Run Test and View Details’
Test Run Details – Is Passed
You can similarly create Test case when Account type is Customer – Direct.