I have an obj1 and field on it field1 and one profile Billing User.
When I click a Custom Button on obj1, it will check the field1 to true for all the profile. However, I want field1 such that it should read only from page layout but it edit from apex, only for Billing User Profile.
If we make field read only from Field Accessibility then this field will not update by apex. I want Field Editable by apex and read only for manually only for specific profile.
(Note: I've 12 record type)
how can I achieve this?
Create a new page layout of object1 for bill user profile/specific profile
and set the field1 to read only from the page layout settings. This will serve your purpose.
Note that a sys admin can still edit that read only field.
For a field countryName in the screen shot, i have applied the same.
On the page layout you have options to make it read only but will not work for system admin they can edit.
Create a new formula field and refer this field and then display that field on UI and remove the old field from UI.
Create new detail page using Visualforce and apex and override the standard page.
Put validation on trigger and use a static variable in condition and set it to true initially now set this variable to false when you update from apex if any user will update from UI then it will give error.
You can use any of the above 4 methods in your use case.