Project Details
  (4.0 Reviews)
Super Clone - clone master and detail records in one click

Project Owner: jing hai li

Created: August 15 2011

Description

Force.com's record clone function only clones the record itself without taking into the account of its "detail/child" records. The Super Clone provides both API (can be directly called from your own code) and visual force page UI access to clone the master and detail records in one go. An example of API access:

//clone an account record (id is a0190000001E3JJ) with all related detail records(contact,opportunity...) //note, detailed records to be cloned can be further declared. By default, it takes all child records.

Clone cc=new Clone();
string parentObjAPIName=cc.returnAPIObjectName('a0190000001E3JJ');
Map<string,string> objLabelobjAPI=cc.getAllChildObjNames(parentObjAPIName,'a0190000001E3JJ');
string clondedParentRecordID=cc.startsClone('a0190000001E3JJ', objLabelobjAPI.values());

That's it, totally 4 lines code.

To use it in a Visualforce page, all you need to do is to pass the master record id to the URL:
yoursalesforce instance.salesforce.com/apex/clone?id=salesforce master record id, e.g:

https://ap1.visual.force.com/apex/clone?id=00190000004ZlVc

Development Team
The project owner is currently the only member of the development team.
Reviews - Showing 5 of 6
5 stars
(by 艾 青 on Sun Feb 05 18:02:42 GMT 2012)
good example

4 stars
(by Naveen Vuppu on Thu Sep 15 08:53:09 GMT 2011)
Please share some more examples.Its very use full.

4 stars
(by Naveen Vuppu on Thu Sep 15 08:53:06 GMT 2011)
Please share some more examples.Its very use full.

5 stars
(by kyle.p02232008 on Mon Sep 12 14:20:56 GMT 2011)
Very useful, saved me the time of having to do this manually for different objects!

2 stars
(by santosh kumar on Thu Sep 08 08:49:06 GMT 2011)
its good but can u give more examples


Tags
master  |  detail  |  clone  |  copy  |  record  |  apex