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.

2
  • On a standard page or Visualforce page? May 28, 2015 at 14:23
  • on a standard page
    – Nick
    May 28, 2015 at 14:23

1 Answer 1

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)
)
10
  • 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
    May 28, 2015 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... May 28, 2015 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
    May 28, 2015 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 :) May 28, 2015 at 14:39
  • 2
    @AbuHamzah Validation rules do not apply on delete.
    – Adrian Larson
    May 28, 2015 at 14:47

You must log in to answer this question.

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