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
Rob Koch 1Rob Koch 1 

Custom clone button question

Hello. I am working on a custom button that will basically create a new record prepopulated with the values on the original record. 

But I do not want any related child items to be carried over. 

How do I ensure that only the values come over, with no related items?
ANUTEJANUTEJ (Salesforce Developers) 
Hi Rob,

Have you tried checking and I found the below link that has a similar implementation but it has child records as well but you could customize it as per your use case to not clone the child records.

>>https://www.salesforceamazings.com/2018/11/how-to-clone-records-using-custom.html

>> http://christopheralunlewis.blogspot.com/2012/04/clone-plus-clone-salesforce-objects.html

>> https://help.salesforce.com/articleView?id=000316430&type=1&mode=1

In above the steps are mentioned as below:

In Lightning Experience
Navigate to Gear icon | Object Manager | Accounts | Buttons, links, and actions | New button or link.
Enter the following in each of the fields:
Label: Clone
Name: Clone
Description: Button to clone Accounts
Display Type: Detail Page Button
Behavior: Display in existing window without sidebar or header
Content Source: URL
Link: /{!Account.Id}/e?clone=1
 
Once the button has been created it will need to be added to the Account page layout. So navigate to Setup | Object Manager | Accounts | Page Layouts.
Edit the Layout you want to add the new button to.
Go to the Mobile & Lightning Actions section and look for the Clone button you created and add it in the Salesforce Mobile and Lightning Experience Actions section of the page layout.
Click Save.

I hope this helps and in case if this comes handy can you please choose this as best answer so that it can be used by others in the future.

Regards,
Anutej
Rob Koch 1Rob Koch 1
Thank you, Anutej. I will have a look at this reference material. All best, Rob