+ Start a Discussion
ArmanMArmanM 

Restrict Fields from being edited after a certain date

Hi, 

I want to restrict a date field and a currency field from being edited. The description for this rule should be that -
If(
a) 20th of the current month

b) Close date is within next month.)
//When above condition is true apply the following rule
-> Lock 'Close Date' and 'Amount' 

 
For example if todays date was September 20th and I had a opportunity where its Close date is in October. The close date and amount should be locked. 

How can I get this rule to apply to opportunities? 

Thank you,

 
Best Answer chosen by ArmanM
Parker EdelmannParker Edelmann
I figured it out. Your syntax and structure is correct. Probability is a percent field, not a number field. Basically, if you have 70%, it doesn't equal 70, it equals 0.70. Why? Because 70% is really 70 percent of 1, or 70/100, which is 0.70.

Anyways the math is not necessarily important (and I did a terrible job explaining it), but just remember that 70% equal 0.70, 100% = 1, etc. and change your validation rule to this:

Probability  >= 0.70
&& (MONTH(CloseDate) = MONTH(TODAY()) + 1)
&& (DAY(TODAY()) >= 20)
&& (ISCHANGED(CloseDate) 
|| ISCHANGED(Expected_Amount__c))

I tested it in my DE and it fired as expected.

Thanks,
Parker

All Answers

Harish RamachandruniHarish Ramachandruni
Hi,
 
  1. Create 2 Records types 1 is default present page layout  .
  2. Another one for create  what u want to lock Make it as details page  Make it as read only field in page layout .
  3.  Assign to 2 nd redord type .
  4. Create schedule apex daily 12:00 Am .
  5. Write query to select id,name from opp where datefield = Today();
  6. Update List Recordtype = 2 nd record type .
  7. If want u can use batch with schedule Apex .


Regards,
Harish.R.
 
ArmanMArmanM
Hi Harish, 

Not sure how that will work. I just want two fields read only and date has to be 20th of each month 
Parker EdelmannParker Edelmann
Hello @AcctMgt,

Instead of record types and apex, you can try this fairly simple validation rule:
 
(MONTH(CloseDate) = MONTH(TODAY()) + 1 || (MONTH(CloseDate) = MONTH(TODAY()) && DAY(TODAY()) =>20)) && (ISCHANGED(CloseDate) || ISCHANGED(Amount))

What this does, is if an Opportunity is closing either this month, or next month and the date is equal to or greater than the 20th, it will not allow changes to the Close Date or the Amount field. Is this sort of what you're looking for?

Regards,
Parker

ArmanMArmanM
Hey Parker, 

Yes, close but I am looking for if an Opportunity is closing next month and the date is equal to the 20th of the current month, then it will not allow changes to the Close Date or the Amount field. 

Thanks
Parker EdelmannParker Edelmann
Then try this validation rule:
 
MONTH(CloseDate) = MONTH(TODAY()) + 1 && DAY(TODAY()) = 20 && (ISCHANGED(CloseDate) || ISCHANGED(Amount))
This will restrict the Close Date and the Amount from being changed only if today is the 20th of the current month, and the Close Date is next month.

Regards,
Parker
ArmanMArmanM
Thanks Parker!
ArmanMArmanM
Hi Parker, 

Just another add on to that validation, I want it only to apply to the opportunities whose probability is greater than 70. I tried the following but that doesn't seem to be doing anything : 

Probability  >= 70
&& (MONTH(CloseDate) = MONTH(TODAY()) + 1)
&& (DAY(TODAY()) >= 20)
&& (ISCHANGED(CloseDate) 
|| ISCHANGED(Expected_Amount__c))

How can I add this on to that validation rule? 

Thanks
Parker EdelmannParker Edelmann
I figured it out. Your syntax and structure is correct. Probability is a percent field, not a number field. Basically, if you have 70%, it doesn't equal 70, it equals 0.70. Why? Because 70% is really 70 percent of 1, or 70/100, which is 0.70.

Anyways the math is not necessarily important (and I did a terrible job explaining it), but just remember that 70% equal 0.70, 100% = 1, etc. and change your validation rule to this:

Probability  >= 0.70
&& (MONTH(CloseDate) = MONTH(TODAY()) + 1)
&& (DAY(TODAY()) >= 20)
&& (ISCHANGED(CloseDate) 
|| ISCHANGED(Expected_Amount__c))

I tested it in my DE and it fired as expected.

Thanks,
Parker
This was selected as the best answer