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
mkchourasiamkchourasia 

How to create the clone of Custom Object

How to create the clone of Custom Object.
I have a requirement which needs the exact replica of the Custom Object for some other business. How can I clone the object itself.
JonPJonP
Your best bet is to use the Force.com IDE to extract your original custom object as an XML metadata file, copy and rename your object, and save it back to the server as a new custom object, identical to the original.
leomeisterleomeister

I also need to clone a custom object. I tried to follow your advise, but IDE does not allow me to rename the copy of the object. The message is "Renaming not supported in this Force.com IDE release. Please use Salesforce.com to rename". I use Summer 2008 version of IDE. I cannot use Salesforce.com as I have to rename the clone object before I can save it to server. What am I doing wrong? I am using Developer organization of SF.com.

 

Thank you.

JonPJonP
You don't actually want to "rename" the object, which is what the IDE's warning message is preventing.  You want to duplicate the object.

To do this, go to the file system and copy-and-paste the .object file to a new file, then refresh your Force.com Project (using the Eclipse built-in Refresh command, not the Force.com > Refresh from Server command).  Once your new .object file appears in the Package Explorer view, right-click on it and select Force.com > Save to Server to push the object up to your organization.
JFAJFA

I had this question to.  Can you tell me exactly how to "copy paste the object to a new file" in Eclipse?  Couldn't figure out the command sequence for this.

 

Thanks very much.

JonPJonP

The easiest way to "clone" a custom object is probably to create a new, empty custom object with the new name, etc., and then to copy-and-paste the other contents from your original custom object into the new one.  For example, you could copy all of the <fields> tags to replicate the custom fields from your original to your new object.

 

However, you can't copy the entire contents of the original to the new object, because the <fullname> field must be unique and match the filename (excluding the extension, e.g. MyCustomObject__c.object has fullname "MyCustomObject__c").

ColinMcGColinMcG

I thought I would clarify this process for anyone Googling along to this item, as I've just gone through a little pain to clone a custom object. JonP's last suggestion is the way to go - you do NOT want to start mucking around with the actual files using Windows Explorer - this will only produce errors and heartarche. Create a new object in Salesforce with an appropriate name and basic settings the same as your original object, then bring this into Eclipse along with the original object. Open both files (found under src->objects) and click on the Source tab (default tab is design) and add the fields by copying/pasting from the old object. Note, however, that you cannot add lookup fields (these produce errors), so you'll need to do this manually once you're done. I'm not sure on the reason why, but don't use an external editor at any point either - this will cause Eclipse to see the file as empty.

JonPJonP

The issue with Lookup fields is kind of indirect.  Currently the Metadata API does not allow you to change the sharing model of a custom object, because this requires a big sharing rules recalculation that would greatly expand the execution time of a deploy() operation when there are large data sets.  Changing a custom object to the detail of a master-detail relationship means you change its sharing model to conform to the sharing rules of the master.

 

This is an overly restrictive rule and we know we need to relax it in the future, but this is how things stand for the moment.

Ram'sRam's
I have a solution here for the clone of custom or standard object in salesforce.
Solution is "iClone" app which Clone standard and custom objects along with any related lists, lookup or master-detail - https://appexchange.salesforce.com/listingDetail?listingId=a0N3000000B39tWEAR
Hope this will resolve the issue for every one :)
Suggestions are welcome :)
John Thrasher 1John Thrasher 1
@Ram's - Not sure why you would post your advertisement here as that page clearly states: Note: This app does NOT support cloning of objects or metadata within setup menu. You can use Eclipse for such needs. 

Also, 5 out of 5 stars for every single reviewer is extremely suspicious.

So no, you didn't resolve anything for anyone. 
iKashiKash
I know this is an older thread but I found something that might help for someone later on:
https://appexchange.salesforce.com/listingDetail?listingId=a0N30000000qb65EAA

Disclaimer: This is a free thrid-party app and use it at your own risk.
rishu rathorrishu rathor
You can use below appexchange tool to clone Custom or standard Object in few clicks:
https://appexchange.salesforce.com/appxlistingdetail?listingId=a0N30000000qDqqEAE