You need to sign in to do that
Don't have an account?
Rachel Linder 20
Formula Field for Contract Term Based on Earliest Date of all Oppty Porducts and Latest Date of all Oppty Products
We are looking to add a field to the Opportunity called Contract Terms. We want this field to look at all products associated with the opportunity and find the earlieast start date and the latest end date?
Any ideas?
Any ideas?
Each time the number of oppty products changes (including a deletion), the rollup summary field is updated on the parent and the process could be activated and therefore the calculations of the Earliest Date/Latest Date by the flow.
The only problem is that mass changes will deactivate the called triggers and the rollup summary fields are mass updated later lonely.
Therefore, the "only" most common solution is an apex trigger that will update new fields based on "creations/updates (status?)/deletions" of the oppty products.
All Answers
"the earlieast start date and the latest end date" is a request and that is not possible with a formula.
You need at least a flow (zero code, replaces a trigger) ( https://help.salesforce.com/articleView?id=flow_lightning_flow.htm&type=5 (https://help.salesforce.com/articleView?id=flow_lightning_flow.htm&type=5) ) called by a process ( https://help.salesforce.com/articleView?id=process_overview.htm&type=5 (https://help.salesforce.com/articleView?id=process_overview.htm&type=5) ) that will update the earliest/latest dates each time an oppty products is created/updated (status?).
How To: Use Flow to Report on the Most Recent Record (obsolete now because there is a new flow builder by default, simpler):
https://salesforceweek.ly/2015/02/how-to-flow-most-recent-record.html
The big problem without an apex trigger is that a process builder cannot be activated with the deletion of an oppty product.
The workaround is to transform a deletion into an update of an end validity date in a new object (not easy here).
If the fields (Earliest Date/Latest Date) are only shown on screen, a small VFP with an apex controller is sufficient.
Otherwise the most common solution is an apex trigger that will update new fields based on "creations/updates (status?)/deletions" of the oppty product.
A daily batch can also update all the values every night (or even every hours).
Each time the number of oppty products changes (including a deletion), the rollup summary field is updated on the parent and the process could be activated and therefore the calculations of the Earliest Date/Latest Date by the flow.
The only problem is that mass changes will deactivate the called triggers and the rollup summary fields are mass updated later lonely.
Therefore, the "only" most common solution is an apex trigger that will update new fields based on "creations/updates (status?)/deletions" of the oppty products.