Ask Search:
Elizabeth EissnerElizabeth Eissner 

How to hide or disable Opportunity detail page Edit button programmatically?

I need a way to hide/disable the Edit button based on a certain condition. Is there a way to do that from a trigger?
Steve MolisSteve Molis
Which edition of SFDC are you using?  Can you explain what the conditions would be that would "lock" the Opportunity?
Praveen EPraveen E
You need to make that page as VF page and create new custom EDIT button check the condition in controller of VF page based on that hide the newly created Custom button.
Elizabeth EissnerElizabeth Eissner
Edition - Enterprise

I have created a cutom object called "Project". When an Opportunity is saved, depending on its Stage, it will be made a Project (new record in Project is created). I want the Opportunity to be locked once it was made a Project.
Praveen EPraveen E
you can lock the opportuniity depending on its Stage
Steve MolisSteve Molis
Is there anything else about the Stage "Project"?  Does "Project" equal Closed/Won?  Is "project" the only Stage that equals Closed/Won?
Elizabeth EissnerElizabeth Eissner
Here's the flow:
1. Create an Opportunity with Stage = let's say "Proposal" (I changed the the picklist values of the Opportunity Stage field).
2. In the "after update" trigger, a new record is created in the Project custom object.
3. Lock the Opportunity that was made project.

Steve MolisSteve Molis
Okay I'm still missing a few things, but long story short there are a few ways you could do this.  The easiest would be to create a Record Type and Page Layout called "Locked" (or whatever) and then update the opportunity Record Type to "Locked".  In the Page layout Editor you can remove the Edit Button and Record Type field from the "Locked" page layout.  
Praveen EPraveen E
Here's the flow:
1. When Opportunity Stage chnages to "Proposal"
2. Lock the Opportunity using trigger or work flow