You need to sign in to do that
Don't have an account?

Read only and accessing through apex
Hi All,
I have a basic question. If I mark the field "Read Only" when i am defining the field. Will my apex code be able to access it and set values? My requirement is the field should be updated only through apex code and not by any other means. Is just hiding the field from the page layout good enough?
If a field is read only for the profile that is executing apex code then it depends on the code. If your code is marked 'with sharing' it will not be able to, but if its marked as 'without sharing' it will be able to.
It's usually not best practices to use 'without sharing', but if you have your class using 'with sharing' you can have an inner class or another class it references use 'without sharing'.