function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
sftechlearnersftechlearner 

Date when first opportunity is changed to closed won?

Hi ,

We would like to create a date field(formula field or a roll up summary field) in the Account level that captures date when the first opportunity associated to the account goes to closed won.
Is there a workaround to do this?

Thank you!!
kaustav goswamikaustav goswami
This is a solution that involves no coding. Please try this out.

1. Create a Roll Up Summary field on Account to count the number of related opportunities - Number_Of_Opp__c
2. Create a text field on Account called First_Opp_Id__c - this will store the Id of the first opportunity that is created
3. Create a date field on Account called - First_Date_Of_First_Opp_Closure__c - this will store the actual date
4. Create a field on Opportunity - Ensure_Single_Execution__c(a checkbox field)
5. Create a WF rule on Opp - this will store the Id of the first opp in a field on the account object
    Evaluation - When a record is created and edited
    Filter - AND(
        ISNEW(),
        Account.Number_Of_Opp__c = 0,
        Account.First_Opp_Id__c = null
       )
6. Create a Field Update on Opportunity and set the value in the Account.First_Opp_Id__c field - with Opportunity Id - associate it with the WF created above
7. Create another WF Rule on Opportunity
    Evaluation - Created and every time the record is edited
    Filter - AND(
         Ensure_Single_Execution__c = false,
         NOT(ISPICKVAL(PRIORVALUE(StageName),"Closed Won")),
         ISPICKVAL(StageName, "Closed Won"),
         Account.First_Opp_Id__c = Id
      )
8. Create two field updates and add that to the WF rule created in the step above
      a. Update the date field on Account with today's date
      b. set the checkbox to Ensure_Single_Execution__c to true

Let me know if this works.
Thanks,
Kaustav