+ Start a Discussion

Proper way to prevent modification of certain fields

What's the correct way to create a field that should not change after the record is created?


I see that there is an ISCHANGED() function for validation rules.  Should I just create a validation rule that sees if any of these fields have been changed?  Should I make the fields read-only?  Will either of those techniques prevent Apex code launched by a user from creating new records?


I'm guessing that a validation rule is more efficient than a trigger.


The fields are used as foreign keys to an external database, and need to be immutable.  Not even an administrator should be able to edit the field.

Jia HuJia Hu
Basically, validation rule is better than trigger in your case.

You can also set up the Field Permissions in each profile, and remove this field from the page layout.

I think cleanest will be for you to use field level security and make it read only for relevant profiles.

Nazeer AhamedNazeer Ahamed

If the value need to be manually keyed in while creating then no modification allowed. best will be validation rule as you mentioned. 


If user no need to key in, then "Auto Number" is best choice as it will be generated automatically and can be used as fkey as well.