0

I have this validation that is supposed to prevent non admins from changing the Close Date once an Opportunity is closed. It seems to be firing when they are changing the stage to Closed Won or Closed Lost. This is what I have:

(
    ISCHANGED(CloseDate) 
    && (ISPICKVAL(StageName,'Closed Won') || ISPICKVAL(StageName,'Closed Lost'))
) 
&& ($Profile.Name != 'System Administrator')

Is there something wrong in my syntax or formula?

1 Answer 1

2

You should be using PRIORVALUE to check only that the previous stage is already closed. As written, it checks if the new stage being set is closed won/lost; it actively prevents non-admin users from closing opportunities at all. Keep in mind that changing to closed won/lost also changes the Close Date by default. You can also be more efficient using the IsClosed field:

ISCHANGED(CloseDate) &&
PRIORVALUE(IsClosed) &&
$Profile.Name != 'System Administrator

Note that IsClosed is a Boolean (checkbox) field, so we don't need to compare it to a Boolean value (== TRUE).

1
  • Thank you sfdcfox! That did the trick.
    – user7417
    Dec 9, 2022 at 19:28

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .