You need to sign in to do that
Don't have an account?
sam_Admin
How to clone related records
I have 2 custom objects, object1(Parent) and object2(Child), i want a clone button on object1 so everytime i clone then it needs to carry over records from object2. I created this button but it doesn't carry over the related records, i know i haven't added any logic to carry the records yet but if anyone can help me here i would really appreciate it
https://na2.salesforce.com/{!object1__c.Id}/e?clone=1&retURL=%{!object1.Id}
https://na2.salesforce.com/{!object1__c.Id}/e?clone=1&retURL=%{!object1.Id}
hope this helps...
Sandeep.
Hello,
Not sure if I got it right but if you are looking for a clone button that clones the parent and its children you can try the approach bellow.
First of all, you have to create a class with a webservice method that will be invoked by a custom button in the parent's object layout that will clone the parent and its children:
After that, you will have to create a custom javascript button and place it at the parent's layout. Once clicked, the button will invoke the clone method and will clone the desired sObject.
Button's code:
This is one way to achieve what you are looking for. Keep in mind that you can change it as much as you want.
Hope to have helped. Regards.
Don't forget to mark your thread as 'SOLVED' with the answer that best helps you.
It walks you throught the steps in reasonable detail.
I think Zuinglio Lopes Ribeiro Junior likely has the right solution and I am hoping he might be able to respond to my recent post since his apex.execute() approach above might solve one of my problems!
Can you please explain how the following works:
080 // Set the parent's Id
081 for (ChildSObject__c child : children) {
082 child.ParentSObjectId__c = parent.Id;
083 }
If I just have an object (detail) that has two master detail relationships could I just assign the object's ParentSObjectId__c to a different master? Or is there something special going on with your code that somehow knows the right "parent" to update?