+ Start a Discussion

Opportunity Save Button Override

I am trying to override the Opportunity save button so that the standard Close Date field is not required on the save.


I have already created an override for the Detail View and the Edit page each of the different record types has its own detail view and edit page.


I know I cannot directly override the button through the Salesforce UI like the Edit button or the Detail View. 

Can anyone provide an example of how this would look? I know I am either over simplifying this or I am over thinking it. I already have a controller extension in place I would just add this save method to it.


This is what I thought it might look like but I am not sure how to say do not output an error if this field is not populated.

public PageReference save(){

// do not require CloseDate Field

 if (CloseDate == null) { //Call a method that says the closedate is not required - This is the part I do not know how to do }


// use the standard controller to perform the save and redirect - will using this still make the CloseDate field required

 return controller.save();



Hmmm, the Close Date requirement is not one I think you can get around as this is enforced on a DML level. This is is the error you would get if you saved with close Date as null:

ERROR - Evaluation error: System.DmlException: Insert failed. First exception on row 0; first error: REQUIRED_FIELD_MISSING, Required fields are missing: [StageName, CloseDate]: [StageName, CloseDate]