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
CritterCritter 

Deep, Deep Cloning and URL.

Basically I need to do a recursive clone of an object and all it's children.

 

I was initially hoping to intercept the standard clone event using a trigger, and capture the clone variable in the query using:

 

URL.getCurrentRequestUrl().getQuery());

 

hoping to find "clone=1" somewhere in the string, but it only returns a null, so I am assuming there is a page redirect or such before the trigger is executed.

 

any suggestions on how to best catch the 'clone' so that I can do my thing and clone all the related items?

Best Answer chosen by Admin (Salesforce Developers) 
ForceMantis (Amit Jain)ForceMantis (Amit Jain)

You can create a custom button, custom visual force page and controller. This will replace standard Clone button. 

 

In this controller you use sobject clone method to deep clone you source object.

 

http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_methods_system_sobject.htm

All Answers

ForceMantis (Amit Jain)ForceMantis (Amit Jain)

Welcome to community Mr. Critter.

 

I am afraid to say that I could not understand what exactly you want to do? 

CritterCritter

I have a top level object: Projects

 

When a project is cloned, I need to clone everything that is attached to that Project. Currently cloning just clones the Project itself. 

 

I wanted to intercept the standard clone of a project so that I could loop through everything attached to it and clone them...

 

I was hoping to use the URL to see if the url contained 'clone=1', which is what is shown when cloning an object, but that doesn't work..

 

Was curious if there are any other ways to 'intercept' a clone event..

 

ps. thank you for the welcome :)

ForceMantis (Amit Jain)ForceMantis (Amit Jain)

You can create a custom button, custom visual force page and controller. This will replace standard Clone button. 

 

In this controller you use sobject clone method to deep clone you source object.

 

http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_methods_system_sobject.htm

This was selected as the best answer
CritterCritter

That is what I figured I would have to do. I was just hoping there would be a way to 'intercept' the standard clone feature.

 

Thanks.