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
Carol_2019Carol_2019 

How can I have a date field auto updated when the opportunities stage changed?

We have a customized field added to opportunity about contract signing date, we want the field is auto filled by the date when the stage of the opportunities changed to "Won- Agreement Signed". as the stage is a picklist field, I cannot use If, but I also failed when I use Case.
This is my formula, it doesn't work. SF said it cannot be used for picklist field.
CASE((StageName  = "Won - AGREEMENT SIGNED & ACCEPTED"),TODAY())
can anyone help me to give a correct script?

thanks very much
Carol
Pankaj ShakyaPankaj Shakya
Hi Carol

Use the following syntax of IF Formula  :  IF(logical_test, value_if_true, value_if_false)

IF( 
ISPICKVAL(StageName , "Won-AGREEMENT SIGNED & ACCEPTED" ),
ContractSigningDate =  TODAY(),
ContractSigningDate = NULL
)

Hope you find this useful.

Regards 
Pankaj Shakya
 
Carol_2019Carol_2019
Hi, Pankja

Thank you very much! I type your syntax and it returns this error :" Formula result is data type (Boolean), incompatible with expected data type (Date)." could you please continue to help?

thanks!
Carol
Jothi SaminathanJothi Saminathan
Hi Carol,

 Please try Workflow field update, 
 
Set the Evaluation Criteria as "Evaluate the rule when a record is created, and any time it's edited to subsequently meet criteria"
 Rule Criteria: StageName Equals "Won - AGREEMENT SIGNED & ACCEPTED"
 Field update: ContractSigningDate =  TODAY()

Please ensure if you have any Process builder using this stage field.

Thanks,
Jothi
Pankaj ShakyaPankaj Shakya
Hi Carol

Please define the type of the formula field as Date.
When creating the formula field on Opporutnity, choose the return type as Date.

Hope this helps you.

Regards 
Pankaj Shakya
Carol_2019Carol_2019
thanks very much. Actually the field is Date type when I created. I just run the script again and got another error: Incorrect number of parameters for function 'IF()'. Expected 3, received 5

hope you give further guidance.

thanks very much
Carol_2019Carol_2019
@Jothi Saminathan thank you for sugguestion! I cannot find the place where I can input rule criteria and fields updates. and we don't have a process builder. I am not sure what happened with the difference.
Pankaj ShakyaPankaj Shakya
Hi Carol

The syntax IF(logical_test, value_if_true, value_if_false) has 3 parameters:
1. logical_test
2. value_if_true
3. value_if_false
It can't have more than 3. Your error says you have entered 5 parameters.

IF( 
ISPICKVAL(StageName , "Won-AGREEMENT SIGNED & ACCEPTED" ),      // locical_test
ContractSigningDate =  TODAY(),                                                                      // value_if_true
ContractSigningDate = NULL                                                                             // value_if_false
)

You can modify the false conditon accordingly. I have mention Null just as a reference.

Hope this helps you.

Regards
Pankaj Shakya
Carol_2019Carol_2019
thank@
Pankaj, the syntax finally accepted by SF.
thank @jothi, I know what you mean when I go back to modify my workflow rule.

now the rule is not working. after I select the stage as Won....., the field is not updated as what I setup.
this is my settings for the workflow rules. the field update is set as 
IF(ISPICKVAL(StageName, "Won - AGREEMENT SIGNED & ACCEPTED"), PO_Contract_Effective_Date__c ,TODAY())

User-added image

it looks correct, why it doesn't take effective?

thanks very much
Carol
Jega DeivaJega Deiva
Hi Carol,
    
  Please use formula editor in "Field update" on WFR :

User-added image
 
    It helps us to update today's date in that "ContractSigningDate" field.

Thanks,
Jega

 
Carol_2019Carol_2019
thanks, Jega