+ Start a Discussion
sultansultan 

How to make a field as "readonly" using a Trigger ?plz helpme?

Best Answer chosen by sultan
Ankit AroraAnkit Arora
First as Randip said what is the use case? As according to me it's not at all a best practice to make field read only via trigger as it can be handled via profiles etc as James said.

But if it is not making field "Read Only" rather stop the users to update it in some specific case then it make bit sense. And you can do that via trigger by checking applying your condition. IF you condition matches then do not update the field.

All Answers

RadnipRadnip
Whats the business reason for wanting to make the field readonly using a trigger?
James LoghryJames Loghry
Why couldn't you solve this with profiles, permissions, and layouts, which is the preferred way to handle readonly fields?
RadnipRadnip
Because Feroz is trying to answer questions in a test maybe??? ;)
Ankit AroraAnkit Arora
First as Randip said what is the use case? As according to me it's not at all a best practice to make field read only via trigger as it can be handled via profiles etc as James said.

But if it is not making field "Read Only" rather stop the users to update it in some specific case then it make bit sense. And you can do that via trigger by checking applying your condition. IF you condition matches then do not update the field.
This was selected as the best answer