+ Start a Discussion
HuluSFAdminHuluSFAdmin 

Deep cloning custom objects

I have custom object called "Placement" which has a Master-Detail relationship with another Custom Object called "Flight". When I clone a Flight, I also want to clone the Placement(s) associated with it.

Any suggestions on how I could do this via APEX or some other mechanism?

Thanks
Chaitanya
mikefmikef
Please read the Apex docs, there is a section for SObject methods.
I think you want to use the clone method but I am not sure what you are trying to do, what business use you are solving.

Clone will also copy the relationships. You still have to save the new cloned SObject to commit it to salesforce.
miteshsuramiteshsura

you said, cloning copies the related lists as well? 

not in my case, I have Product Bundle custom parent object, and Line Items child custom object. 

When I hit clone on Master record, it does not copy related  child list?? any reason why?? 

is it because they are custom objects?? 

 

I really need this going, thanks for the time..

jbardetjbardet

hey Mitesh.. funny seeing you in this thread!

 

I just ran into the same problem when cloning these Estimates I'm working on. Hopefully you've found a solution by now!!