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
Pavan kumar 546Pavan kumar 546 

Any One Pls Help To write Trigger For Below Senario?

my due date is 25/10/2015.  If I change it to 20/10/2015, I want to be allowed to save. If I change it to 30/10/2015, I want to get an error.
Hi Pawan,
Which object you need to write trigger ,Here question is you have any staic date or you want to restrict user to select past date .Only you can change future date .

If yes then try with belwo code ,belwo code is in opportunity if you change closedate to past date it wilgive you error .
trigger PastDateRestriction on Opportunity(before update){
        if(opp.CloseDate!=Trigger.oldMap.get(opp.Id).CloseDate&& opp.CloseDate< Trigger.oldMap.get(opp.Id).CloseDate){
            opp.addError('You can not change to past date ');
Change your object name and field name accoringly and let me know if it helps !!