function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
CharlesOliveriaCharlesOliveria 

How to restrict updates of a field to Apex Program only?

We have a visualforce page and apex to handle configuration of our line items on an opportunity.  How do we restrict updating of the line item fields to only allow update of these records by code?   We don't want the users to update these fields manually.  

We can't change the CRUD permissions to read only because they won't be able to update via the code. 

Can this be accomplished with validation rules or triggers?

Best Answer chosen by CharlesOliveria
Dayakar.DDayakar.D
Hi Charles,

If you don't want user to edit field manually, just make that fields readonly from the pagelayout.

Best Regards,
Dayakar.D

All Answers

Dayakar.DDayakar.D
Hi Charles,

If you don't want user to edit field manually, just make that fields readonly from the pagelayout.

Best Regards,
Dayakar.D
This was selected as the best answer
CharlesOliveriaCharlesOliveria
Thank you, I forgot to mention,I also need to prevent users from deleting but the code needs to be able to delete.  I took off the new button so that prevents them from adding.    
Dayakar.DDayakar.D
You can override delete button with visual force page and display some text like "Record deletion is not allowed manually"
and put some button to redirect to back.

Best Regards,
Dayakar.D