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
Manish Verma 4Manish Verma 4 

validation rule on opportunity object

hi all, 
when opp stage is "closed won" then none of the fields should be editable. i have created a validation rule for this.
AND( ISPICKVAL( StageName ,"Closed won"),OR(ISCHANGED( Type ),  ISCHANGED( Amount ), ISCHANGED( LeadSource ), ISCHANGED( CloseDate )) )

now when i change the stage field from qualification to closed won along with the changes in any other field. record should be saved but its not getting saved.
what mistake i am doing ? pls help.. do let me know is there anyother way to do this..Thanks
Best Answer chosen by Manish Verma 4
Vignesh P 6Vignesh P 6
Hi manish,
 
                 Edit your formula field like below. 

=====================================

AND (
ISPICKVAL (StageName, "Closed won"), NOT (ISCHANGED(StageName)), 
OR (ISCHANGED(Type), ISCHANGED (Amount), ISCHANGED (LeadSource), ISCHANGED (CloseDate)) 
)

=========================================

If there are any issues, Let me know.


Thanks,

Vignesh P

All Answers

Pradnya BPradnya B
You should check PREVIUS VALUE for Stage field along with the existing formula.

Thanks.
Vignesh P 6Vignesh P 6
Hi manish,
 
                 Edit your formula field like below. 

=====================================

AND (
ISPICKVAL (StageName, "Closed won"), NOT (ISCHANGED(StageName)), 
OR (ISCHANGED(Type), ISCHANGED (Amount), ISCHANGED (LeadSource), ISCHANGED (CloseDate)) 
)

=========================================

If there are any issues, Let me know.


Thanks,

Vignesh P
This was selected as the best answer
Manish Verma 4Manish Verma 4
Thanks Vignesh! your formula is working. :)
AnjaneyluAnjaneylu
Hi Vignesh,
May i know why you have used  
NOT (ISCHANGED(StageName)), 

Thanks and Regards
Anji
 
Manish Verma 4Manish Verma 4
Hi,
Pls try this..

AND( (ISPICKVAL(PRIORVALUE(StageName ), "Closed Won")),OR(ISCHANGED( Type ), ISCHANGED( StageName ), ISCHANGED( Amount ), ISCHANGED( LeadSource ), ISCHANGED( CloseDate )) )

Thanks
Vignesh P 6Vignesh P 6
Hi anji  & Manish,

Consider you want to update the stageName field as 'Closed won' and  some fields like type, amount etc 'in a single update'. If you have not used 
'NOT (ISCHANGED(StageName))' means, the above action won't be happened. Manish clearly told this in his requirement.

Else, you can use 'ISPICKVAL(PRIORVALUE(StageName ), "Closed Won")'. Both are correct..


Try this, you can understand clearly.

Thanks,
Vignesh P