1

I want to restrict update of ll the fields on my custom object record after it has been created. I am trying this with a validation rule by providing ISCHANGED( LastModifiedDate ) . Means if LastModifiedDate is update then run the validation rule. But it is not working for the update on record for the first time. For 2nd time its throwing the validation error. Same is happening if I try giving in rule as CreatedDate <> LastModifiedDate.

Can anyone explain me why this is happening ? And what might the solution for this ?

Note : I have a trigger on same object which fires AFTER INSERT and when the Status = Closed to update the records fields which are calculating some value. I want this trigger to fire and update the fields and then insert the record with the updated value. If I try to put the VR on all the fields like OR(ISchanged(Field1) , ISChanged(Field2)) to restrict record update after create then upon the creation of record itself validation rule is firing and restricting to even insert the record.

1 Answer 1

1

Instead of using the last modified date just use the ISNEW() function by inverting it:

IF( NOT(ISNEW()), true, false)
5
  • This is working if I update the record. But when I make status = closed then trigger is firing which updates the record at the time of insert and then Validation rule is also firing and not allowing to insert record itself
    – Ruchi
    Commented May 3, 2016 at 8:20
  • If NOT(ISNEW()) or AND(PRIORVALUE(Status) not equal to 'old', Status equals 'old')? Commented May 3, 2016 at 8:31
  • This wont work as what is happening is that when I make Case Status = Closed then a child record is inserted via trigger(on case) in another custom object. Upon this custom object I have one more trigger which updates few fields just after insertion since it was not happening in case trigger. This custom object record I do not want to be modified after insertion since it has kind of 'CaseHistory' data.
    – Ruchi
    Commented May 3, 2016 at 9:20
  • OK then you have two options: 1) you make a check box on the record and only update when that check box is checked via an automated process (don't out the check box on the page layout) and then uncheck it at the end if the process in a workflow or 2) create a rollup summary to count your case history records and if the case has 1 or more history records then do not allow it to be modified. Commented May 3, 2016 at 10:29
  • hmm...ok...i'll try these options. Thanks for your help.
    – Ruchi
    Commented May 3, 2016 at 11:30

You must log in to answer this question.

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