Pages

Sunday, November 30, 2014

Salesforce: Opportunity Close Date changed to Today's Date

Salesforce users may experience when they close won an opportunity, the close date change to today, but that is not what the user want. What is happening? Is admin or developer write some code on this?

Let us analyse the behaviour. It is not a customization, but out of the box of Salesforce functionality, and we cannot turn it off with a checkbox tick.
  • If Opportunity Stage is not Closed Won and has Close Date in the future; when user change the Stage to Closed Won, the Close Date will automatically change to today's date
  • If Opportunity Stage is not Closed Won and has Close Date in the future; when user change the Stage to Closed Won and also change the Close Date to some other date (future or past), the Close Date will not change
  • If Opportunity Stage is not Closed Won and has Close Date NOT in the future; when user change the Stage to Closed Won, the Close Date will not change
For this scenario (item 1 above), we can use Workflow + Field Update to stop this auto Close Date change behaviour to Today's date.

Workflow:
Rule Criteria
ISCHANGED(StageName) &&
IsWon = True &&
CloseDate = TODAY() &&
PRIORVALUE(CloseDate) > TODAY()

** you cannot use Evaluation Criteria = created, and any time it’s edited to subsequently meet criteria, because ISCHANGED function is not valid with this criteria.


Field Update:
Field to Update Opportunity: Close Date
Formula Value PRIORVALUE(CloseDate)


But, since the Close Date has changed to TODAY, then we change it back to the Original Close Date, when we look at the field history, notice they are two transaction on Close Date.


Another issue with this workflow, if user have open Opportunity with Close Date in the future, when user change the Stage to Closed Won and also change Close Date to Today at the same time, system will change it back to the original Close Date, because it match rule criteria in Workflow.





No comments:

Post a Comment