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
QQQQQQQQQQ 

how to override a standard save button functionality in salesforce

I have created the custom object.My requiremenet is i need to change the vendor name . So when I change the vendor name i need to get a popup box with check box yes or No to select.

In my custom object ,I have edit option to change the Vendor name but when I save I need to get the pop up box with check box.So i need to overide this save option but in the object under button& link secton I m not able  to  see save button .so  how I can override the save  button  
for creating the popup box please suggest .Thanks in advance .
Best Answer chosen by QQQQQ
Manish  ChoudhariManish Choudhari
Hi Shabnum,

You cannot override it from Buttons and Links option. Follow below approach for this:
1. Create a visualforce extension class. https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_controller_extension.htm
2. Include the extension in your Visualforce Page
3. Define another a save method in the visualforce extension
public PageReference save() { 
// write your custom functionality code here
// this code will be executed instead of standard Save functionality
// once the user wil click on Save button
// So you must write your save logic as well here
}

4. Now the above code will be executed instead of standard save functionality, this way you can achieve this.



Please mark this as best answer if this answers your query.

Check my online presence here: 
My Blog: http://sfdcfacts.com/
Youtube Channel: https://www.youtube.com/SFDCFacts
LinkedIn: https://www.linkedin.com/in/manish-choudhary/
Trailhead: https://trailhead.salesforce.com/en/me/manish-choudhari
Twitter: https://mobile.twitter.com/manish_sfdc 

All Answers

Manish  ChoudhariManish Choudhari
Hi Shabnum,

You cannot override it from Buttons and Links option. Follow below approach for this:
1. Create a visualforce extension class. https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_controller_extension.htm
2. Include the extension in your Visualforce Page
3. Define another a save method in the visualforce extension
public PageReference save() { 
// write your custom functionality code here
// this code will be executed instead of standard Save functionality
// once the user wil click on Save button
// So you must write your save logic as well here
}

4. Now the above code will be executed instead of standard save functionality, this way you can achieve this.



Please mark this as best answer if this answers your query.

Check my online presence here: 
My Blog: http://sfdcfacts.com/
Youtube Channel: https://www.youtube.com/SFDCFacts
LinkedIn: https://www.linkedin.com/in/manish-choudhary/
Trailhead: https://trailhead.salesforce.com/en/me/manish-choudhari
Twitter: https://mobile.twitter.com/manish_sfdc 
This was selected as the best answer
QQQQQQQQQQ
thanks i wil try this out 
QQQQQQQQQQ
Hi Manish,

As I m new to salesforce .Can you please let me know that we can make popup box with check box and we can make the pop upbox  to be visible to particular feild.It means I need this pop up box to come  when I am editing and saving the Name of vendor 
Manish  ChoudhariManish Choudhari
Yeah, it can achievable in both Visualforce and Lightning. 
Check out this link which has popup modal example in Visualforce: http://www.salesforcegeneral.com/salesforce-modal-dialog-box/

In Lightning use overlay component: https://developer.salesforce.com/docs/component-library/bundle/lightning:overlayLibrary/documentation 

Let me know if this helps.

**Please mark this as best answer if this answers your query.**
Thanks,
Manish Choudhari
14x Certified Salesforce Architect

Certification link: http://certification.salesforce.com/certification-detail-print?conId=003G000002gRrrEIAS
My Blog: http://sfdcfacts.com/
Youtube Channel: https://www.youtube.com/SFDCFacts
LinkedIn: https://www.linkedin.com/in/manish-choudhary/
Trailhead: https://trailhead.salesforce.com/en/me/manish-choudhari
Twitter: https://mobile.twitter.com/manish_sfdc
QQQQQQQQQQ
Hi Manish,
can we check if a field is changed before save to display in vf page.
Akanksha Dubey 7Akanksha Dubey 7
Hi Manish,

I have a requirement to display a warning message on opportunity object's detail page if user enters agreement start date earlier than today ,I can't use validation rule as I have to save the records after showing that error message.Please help me how to achieve this