How to deep clone parent in Salesforce Stack Exchange?
I have a requirement to deep clone (Parent -> Child -> Grand Child) records by clicking a button at the Parent Level. I believe Salesforce supports only Clone at the Parent Level, it does not have Deep Clone Out Of the Box.
How to clone great grand child in Salesforce?
Hence may not actually compile.Please feel free to make any changes. Parent>Child>Grand child>Great grand child can be achieved through couple of inner classes which will be served as a storage while we iterate through and identify all levels of parent and child we wish to clone. Need to make use of Custom Settings.
Can you use external IDs in a clone?
You could leverage the power of External Ids to join up the objects and use the sObject Clone Method. External Ids let you dynamically match the records, without having to explicitly set the ids of the parent records being created in the clone.
Is there a way to deep clone a sobject?
The SObject.clone method and also JSON support can help build solutions to achieve this in code, but there is no platform deep clone. SObjectDataLoader.cls: I’ve recently leveraged the JSON Apex support to implement a native SObject import/export that has the same requirement.
Is there a deep clone method in apex?
Apex: In terms of building a solution in Apex code, there is some partial support for this you can leverage. The SObject.clone method and also JSON support can help build solutions to achieve this in code, but there is no platform deep clone.
What is the most efficient way to deep clone an object in?
If you do not use Date s, functions, undefined, Infinity, RegExps, Maps, Sets, Blobs, FileLists, ImageDatas, sparse Arrays, Typed Arrays or other complex types within your object, a very simple one liner to deep clone an object is: JSON.parse (JSON.stringify (object))