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
Harish1234Harish1234 

how to relate the cloned record with existing record ?

HI,
how to relate the cloned record with the existing record?

i have clone records in opportunity but how to relate cloned records with existing records so that if any changes are done it should be apper in cloned records and as well as when i click that cloned record the record related to that one should apper ... will any one help ... (eg:- Bank renewal process)
Best Answer chosen by Harish1234
Harish1234Harish1234
hi
bob
              finally i got soultion for my requirement .... 
Thanks for u all,

All Answers

Bhawani SharmaBhawani Sharma
You can create a new field like Parent Record Id and place it on page layout. 
Create a new Clone buttom and create the same URL as standard one + add a new URL parameter. This new parameter key will be you new field id and value will eb your's main record Id:
Like, new field metadata id is 00N1258hytshjf5
https://na6.salesforce.com/{!Opportunity.Id}/e?clone=1&00N1258hytshjf5={!Opportunity.Id}
bob_buzzardbob_buzzard
If you are looking to keep the cloned record in step with the original record, so that any field updates are replicated to both, you'll need set up lookup fields to tie the opportunity and the custom object together, then build some synchronization functionality via a set of triggers.  You'll need after update triggers on opportunity and your custom object that figure out which fields have changed and apply the same changes to the related custom object or opportunity. You can get at the field list via the sobject describe calls.   You might also need after delete triggers if you want the delete the opportunity/custom object when the  related custom object/opportunity is deleted.

You'll also need to train your administrators so that when they add a new field to the opportunity sobject, they replicate that change in the custom "shadow" object and vice versa, otherwise you'll end up trying to update fields that don't exist.
Harish1234Harish1234
will u able to share me the sample code if possible 
bob_buzzardbob_buzzard
I don't have any sample code to share I'm afraid - I've only done this for customers in the past so they own the code/IPR.  It wasn't a huge amount of work as I recall.
Harish1234Harish1234
ok.. fine let's i will try from my end ....
Harish1234Harish1234
hi
bob
              finally i got soultion for my requirement .... 
Thanks for u all,
This was selected as the best answer
Mohini Katiyar 9Mohini Katiyar 9
Hi Harish,
Can you please tell me which solution worked for you?
Thanks in advance.