Tuesday, September 9, 2014

Custom clone button in salesforce

Custom clone button in salesforce 

Salesforce provides Clone functionality for some standard objects(Standard Clone button),
However some standard objects do not have this button. For this purpose of cloning we will need to create custom button that will perform the functionality of cloning.

This cloning functionality can be achieved by writing a javascript for this custom button.

As an example lets create a custom button "Clone" on account that will clone the record.

Simply override your custom button "Clone" with the following java script and you will have your custom Clone button that functions exactly like standard clone button

{!REQUIRESCRIPT("/soap/ajax/22.0/connection.js")} 
window.parent.location.href="/{!Account.Id}/e?&deepclone=1&retURL=/{!Account.Id}";

retUrl specifies the location where you want to be on press of back button.






4 comments:

Matt said...

Thanks, this works great. Curious if there's a way to exclude a single custom field from being cloned when using this button? Like could I add a parameter to pass a null into that specific field, and if so how would I do that?

Matt said...

Thanks, this works great. Curious if there's a way to exclude a single custom field from being cloned when using this button? Like could I add a parameter to pass a null into that specific field, and if so how would I do that?

Matt said...

I figured out I can just add the parameter to the href, so changed it to:

href="/{!Account.Id}/e?&deepclone=1&retURL=/{!Account.Id}&CustomFieldID="

Works great.

Divya Anugu said...

Hi, How to write java script in case of drop down fields. I want to assign a default value to a drop down field when we clone the record

Post a Comment

 
| ,