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
deepa_tansendeepa_tansen 

How to create multiple record types in an object by mirroring one existing record type

Is there any way by using ANT or Eclipse we can create multiple record type in one object by mirroring one existing object?

 I have to create more than 200 record types in one object and also asign the same page layout, profiles which is existing in one record type from which we are mirroring those record types.

Any help will be welcome.

 

Thanks,

Deepa

Best Answer chosen by Admin (Salesforce Developers) 
sandy_sfdcsandy_sfdc

IMO, there is no such way to do that. You can vote on this idea:

 

https://success.salesforce.com/ideaView?id=08730000000BreSAAS

All Answers

sandy_sfdcsandy_sfdc

IMO, there is no such way to do that. You can vote on this idea:

 

https://success.salesforce.com/ideaView?id=08730000000BreSAAS

This was selected as the best answer
ForcepowerForcepower

Deepa,

 

Creating 200 record types by hand is obviously a pain. I would suggest looking at querying the existing record types and cloning them through some custom code:

So as an example, if your original object is Account,

List<RecordType> recTypes = [Select r.SobjectType, r.NamespacePrefix, r.Name, r.IsPersonType, r.Id, r.DeveloperName, r.Description, r.BusinessProcessId From RecordType r where SObjectType = 'Account']

String oldObjName = 'Account';

String newObjName = 'myObject';

 

for (RecordType recType : recTypes) {

    RecordType newRecType = new RecordType();

   newRecType.SObjectType = newObjName;

   newRecType.Name = recType.Name.replace(oldObjName, newObjName)

   newRecType.DeveloperName = recType.DeveloperName.replace(oldObjName, newObjName)

//etc

   newRecTypes.add(newRecType);

}

insert newRecTypes;

 

I'm not sure about the Layouts. Anyway, worth trying this for the record types instead of trying to do it all by hand.

 

Best,

Ram