In this scenario we have a custom field on the Opportunity Form called: All Items Complete.
This is a locked field with a default value of No.
The business rule should update this field on the Parent Opportunity to Yes only when all child Opportunity Products are set to a Status of Complete.
N52 Formula Manager Solution
The Formula Manager solution works like this,
- A formula of type 'Save To Parent' is created
- It is configured so that it executes each time the Status Reason field changes on the Opportunity Product entity.
- On execution it counts all the child Opportunity Product records for the Parent Opportunity
- It then counts all the child Opportunity Product records for the Parent Opportunity with a status of Completed
- Finally it compares the counts, if the numeric values are the same then we know all the child records are Completed.
- If true the All Items Complete field on the Parent Opportunity record is set to Yes.
N52 Formula Manager Steps
The following set of steps outline how to create this Formula
- Create a new formula of type 'Save To Parent'
- Set the Source Entity to 'Opportunity Product'
- Set the Source Property to 'Status Reason'
- Set the Relationship field to 'opportunityid (opportunity)'
- Set the Target Property to 'All Items Complete'
- Copy & paste the formula below into the formula
- Replace the value in the formula for desired status reason with the appropriate one by clicking on the Source tab on the left, selecting status reason and then 'Completed'
- Click save
- You are now ready to test
if(FindCount('opportunityproduct', 'opportunityid', [opportunityproduct.opportunityid], 'opportunityid', '0', true ) = FindCount('opportunityproduct', setfindand('opportunityid', 'new_statusreason'), setfindand([opportunityproduct.opportunityid],'100000001'), 'opportunityid', '0', true ) , true, false )
Wizard - FindCount
Please see below the wizard you can use to create the FindCount() function call used in this formula.
Note to find the value for Equals Value, you will need to go to the Source tab and search for "opportunity"