This is how you can create a new custom object with the same fields as an existing custom object:
1) Download custom objects in Eclipse
– right-click the project in the ‘Package Explorer’ window
– in the popup menu, select ‘Force.com/Project Properties’
– in the properties window, select ‘Force.com/Project Contents’
– click ‘Add/Remove’, then make sure that the ‘objects – custom component’ is checked
– click ‘Apply’ and respond Yes to the ‘Refresh Project From Server’ dialog
2) Create new object in Eclipse
– right-click the ‘objects’ folder, then select ‘New/Custom Object’
– give it a label, plural label and a name, then save it
3) Copy existing object fields to the Clipboard
– right-click the object, then select ‘Open With/Text Editor’
– copy to the Clipboard the part from the first line of <fields> to the last line of </fields>
– it is usually between <enableReports> and <label>
4) Insert fields into the new object
– right-click the new object created in step 2, then select ‘Open With/Text Editor’
– locate the line with <enableReports> and paste the Clipboard contents right below it, before the <label> line
5) Repeat steps 3 and 4 for any other needed configurations
– for example, you may need to copy the lines with the following tags: <listViews>, <searchLayouts>, <validationRules>, <recordTypes>
6) Save the new altered object
– look at the ‘Problems’ tab at the bottom for any error messages, they will indicate what you need to change to make the object accepted
– problems to look for: relationship names will need to be changed to be different from the existing object’s relationships ( <relationshipLabel> and <relationshipName>)
– focus on first renaming relationship names like below to avoid duplicates and the rest of the formulas should work thereafter (the errors xxx__r doesn’t exist are because a relationship could not be created due to duplicate relationship names)
– after all errors are resolved, the object will be saved
Comments
One response to “How to clone a custom object in Salesforce/Eclipse”
awesome