2

EDIT:

On a standard page. NOT using VF page

Is it possible to write a validation rule or any approach to make a field disabled once the user save?

I have a page with couple of fields including lookup and once the user save the record I like to prevent user from changing the lookup fields.

  • On a standard page or Visualforce page? – Brian Mansfield May 28 '15 at 14:23
  • on a standard page – Nick Kahn May 28 '15 at 14:23
3

You can add a validation rule that uses ISCHANGED to compare the values of the lookup fields to their previous values. If the user is attempting to change any of the lookups, the rule will throw an error:

OR(
  ISCHANGED(Lookup_1__c),
  ISCHANGED(Lookup_2__c),
  ISCHANGED(Lookup_3__c),
  ISCHANGED(Lookup_4__c)
)
| improve this answer | |
  • got it and its one way to approach the problem but why not just directly work on validatin rule ischanged? instead of adding a field (checkbox) and check against it?, can you post the code how you will check the ischanged in validatin rule – Nick Kahn May 28 '15 at 14:33
  • 2
    Because validation rules are applied upon creation and edit of records. You need a flag so the rule knows contextually if it should apply the rule... – Brian Mansfield May 28 '15 at 14:34
  • you have said validation rules are applied upon creation and deletion of records but will this also apply editing and updating the existing records? – Nick Kahn May 28 '15 at 14:36
  • @AbuHamzah Actually I was wrong - ISCHANGED isn't enforced on creation, I just tested it...I'll update my answer. Thanks for keeping me honest :) – Brian Mansfield May 28 '15 at 14:39
  • 2
    @AbuHamzah Validation rules do not apply on delete. – Adrian Larson May 28 '15 at 14:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.