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
force shahidforce shahid 

Validation rule for date field when year only changed

Hi friends,

I want to create a Validation rule in opportunity object. When year is changed in Close Date field in Opportunity object  , i need to display error msg to fill the reason into another field. 
How to write VR for this one.

VR for only year changed in Close Date field
Best Answer chosen by force shahid
sfdcMonkey.comsfdcMonkey.com
hi use below validate rule 
YEAR(CloseDate) <> YEAR(PRIORVALUE(CloseDate))
i hope it helps you.
  Let me inform if it helps you and kindly mark it best answer if it helps you so it make proper solution for others
thanks 
sfdcmonkey.com 

All Answers

sfdcMonkey.comsfdcMonkey.com
hi use below validate rule 
YEAR(CloseDate) <> YEAR(PRIORVALUE(CloseDate))
i hope it helps you.
  Let me inform if it helps you and kindly mark it best answer if it helps you so it make proper solution for others
thanks 
sfdcmonkey.com 
This was selected as the best answer
force shahidforce shahid
Hi Piyush,

Thank you so much. It's Working.
Thanks,
Shahid.
 
force shahidforce shahid
Hi Piyush,

ABove condition is working . 

y exact requirement is when i change year in close date then i need to select one value from picklist field.

I write a VR , its working only if picklist field is empty. 

But my requirement is when year is changed , then enter the picklist field.
VR :

AND(YEAR(CloseDate) <> YEAR(PRIORVALUE(CloseDate)),  
ISPICKVAL(Push_reason__c,)
)
 
sfdcMonkey.comsfdcMonkey.com
try this one,
AND(YEAR(CloseDate) <> YEAR(PRIORVALUE(CloseDate)), 
ISBLANK(TEXT(Push_reason__c) ) 
)

Thanks
force shahidforce shahid

Thanks ,
ShahidHi Piyush,

Its working only on Push_reason__c picklist field is empty. If  Push_reason__c  field have a value , and year is changed in close date field , then error message is not display.

My requirement is : When year is changed in Closed Date field , then show the error msg in to Push_reason__c  field , if it has value or not .