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
johutchjohutch 

easy way to clone objects?

Hello all,

I'm find myself with having the task of creating a duplicate contract object.  I wanted to know if there is an easy way to do this in the force.com ide or maybe through an api program.

I would hate to have to create manually every single field for a contract.
Best Answer chosen by Admin (Salesforce Developers) 
JonPJonP
With the Force.com IDE, it's fairly easy to clone a custom object.  However, standard CRM objects (like Contract) do not expose their standard fields for editing in the IDE--since they can't be changed or migrated--only their custom fields.

You still may find value in using the IDE to create a large number of fields, as you can copy-and-paste the XML sections for fields within a .object file very easily.  You'd still need to go back and configure FLS and page layouts later, but it beats running through the Create Custom Field wizard over and over again.

All Answers

JonPJonP
With the Force.com IDE, it's fairly easy to clone a custom object.  However, standard CRM objects (like Contract) do not expose their standard fields for editing in the IDE--since they can't be changed or migrated--only their custom fields.

You still may find value in using the IDE to create a large number of fields, as you can copy-and-paste the XML sections for fields within a .object file very easily.  You'd still need to go back and configure FLS and page layouts later, but it beats running through the Create Custom Field wizard over and over again.

This was selected as the best answer
johutchjohutch
thank you JonP.

i'll use the ide to minimize the amount of work there will be for creating the fields.
Jon Mountjoy_Jon Mountjoy_
I wonder if you can cheat and use the describe calls (See the Apex docs) to write a program that programmatically does this using, for example, the metadata API.

Regards,
Jon