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
arunatascarunatasc 

Clone to be called from Trigger.

Hi guys,

here we have a requirement,

we have four record types,

after saving a record with any record type, we need to get clone from the saved record and this cloned record should be put/assigned with a particular RecordType Id

in short, any record saved should be cloned and the cloned one to be assigned with a specific record type.

 

How to do this!

Ankit AroraAnkit Arora

Lets say I need to clone the Account here is the sample code :

 

Account acc =[select Id,Name from Account where id='XXXXXXXXXXXXXXX'];
Account newAcc = acc.clone(false, true);
newAcc.Name = 'Cloned Account Name - ' + acc.Name;
insert newAcc;

 In above sample I have cloned account and just changed the name. Like this you can change the record type.

 

Thanks

Ankit Arora

Blog | Facebook | Blog Page