Business Use case:
- Tulip has been working as a Salesforce consultant for a manufacturing company. One day, she was assigned a new requirement to just notify sales users that the product they select under the opportunity line with the discount has been approved to sell for a related project or not.
The steps of procedures:
First of all, a project object and a requested product object with all required fields must be created before building the flow.
** Entry criteria **
- Click Setup > search for "Flow" from the quick find box.
- Select Flows then click on the "New Flow".
- Select the "Record-Triggered Flow option" and then select "Freeform".
- Edit the configure trigger by following: 4.1. Trigger the Flow When: A record is created or Updated 4.2. Run Flow: Before the record is saved
- Choose Object: OpportunityLineItem
-
Select Condition Requirements: All conditions are met (AND) and set the condition
- Field: Product2Id
- Operator: Does not equal
- Value: EmptyString (NotNull)
When to Run the Flow for Updated Records: Every time a record is updated and meets the condition requirements
** Get Record Element **
- Under "Toolbox" > select "Element".
- Drag a "Get Record" element into canvas (working area).
- Enter label "Auto populate"
- Select the Object: Request Product Discount.
- Filter for the record. **This step is to search for the desired record.
Entry the conditions for finding the record.
- Project_c = OpportunityLine.Opportunity.Project_c
- Product_c = OpportunityLine.Product_c
- Req_Discount__c Greater or equal OpportunityLine.Discount
- Status__c = Approved
Sort Request Discount (Product) Records: Not sort
How Many Records to Store: Only the first record
How to Store Record Data: Automatically store all fields
Done!!.. Kidding.. There are 3 elements to go!!. Don't give up>)
** Decision Element **
Now we will use the Decision element to check the size of the previous step.
- Drag the decision element from the toolbox.
- Label it as "Found in project"
- Input the conditions:
- Condition Requirements to Execute Outcome: All conditions are met.
- Resource: {!Requested_Product_c.id}
- Operator: not null
- Value: False
- When to Execute Outcome: If the condition requirements are met
- Change the default outcome label to "Not found in project"
** Assignment Element **
There are 2 elements we need to create.
The first one is when the record does meet the criteria.
- Drag the "assignment" element
- Set Variable Values:
- Variable: OpportunityLine.Approved_in_Project__c
- Operator: Equal
- Value: TRUE And the second one is when the record does not meet the criteria.
- Drag the "assignment" element
-
Set Variable Values:
- Variable: OpportunityLine.Approved_in_Project__c
- Operator: Equal
- Value: False
Connect it all together like the picture below.
Click "Save" and "Activate" to finish building the flow. :)))
Finally, don't forget to test after we finish developing.. :)
Add product to the opportunity line item with the discount.
After saving, you will see the "approve in project" checkbox is checked. If you discount greater than 25% that I set before, it will be unchecked.
Top comments (0)