So I've just come across this as part of Salesforce best practices for validation rules.

Avoid using the IsClosed or IsWon opportunity merge fields in validation formulas. Instead, use the ISPICKVAL function to determine if the Stage contains the appropriate value. For example, this validation formula makes a custom Project Start Date field required whenever the Stage is Closed Won. e.g. AND(ISPICKVAL(StageName, "Closed Won"), ISBLANK(Project_Start_Date__c))

I've always tended to use "IsWon" or "IsClosed" as it is cleaner than referencing multiple closed or won stages (which may change in the future).

Does anyone have an idea what the reason against using these "merge" fields are?

  • I believe the answer is that as these are formula fields, they won't have the values you expect if the transaction involves transitioning from a non-won state to a won state. They work perfectly well, for example, if Opportunity is already Won and you want to prevent other edits; they also work great as filters in reports and listviews. Some discussion on this here. You can run your own experiments to confirm.
    – cropredy
    Mar 12 at 16:58
  • @cropredy You are correct; calculated values are loaded only when a record load occurs, which happens twice in the transaction lifecycle.
    – sfdcfox
    Mar 12 at 19:32
  • That's weird. It seems that IsWon/IsClosed works correctly now. As a result, my answer wasn't correct, so I've removed it. I have two theories why they don't recommend using those flags: (1) an administrator might be surprised later when they add a new closed/won state and get the validation error, or (2) the documentation is simply outdated even though they fixed the problem.
    – sfdcfox
    Mar 13 at 12:42
  • @sfdcfox -- my bet is on #2
    – cropredy
    Mar 13 at 21:17
  • thanks sfdcfox cropredy
    – Dan Beer
    Mar 14 at 10:23


You must log in to answer this question.

Browse other questions tagged .