You need to sign in to do that
Don't have an account?
dcarmen66
Clone Opportunity Button
It looks like the standard Clone button on the Opportunity only clones the fields that are part of the current page layout. Can anyone tell me if I'm correct in that assumption? I have fields on the Opportunity that I need to be cloned that are not part of the layout. Will I need to override the button in order to use the Apex clone method? Has anyone seen this or have any other solutions for this?
Thanks!
Dan
When you clone any record only the part on detail is cloned. So only the field on layout will be cloned. Even in Apex also it works like that see an Example :
I have a Contact c with FirstName = 'TestFirstName' , and LastName='TestLastName'
in My apex
Contact con = [Select LastName from Contact where LastName='TestLastName' limit 1];
Contact cloneofCon = c.clone(false);
insert cloneofCon;
now in above cloneofCon will not have first name as TestFirstName, first name will be null but if I do this
//queries first name also
Contact con = [Select LastName , Firstname from Contact where LastName='TestLastName' limit 1];
Contact cloneofCon = c.clone(false);
insert cloneofCon;
now i wil have firstname also
Now to solve your issue you can create a VFP and Overrride your Clone button , pass the id of your opportunity as query parameter , in page level action ( write a method in controller for this page level action) just fetch all the fields of opportunity and clone .
Let me know if any issues in it.
All Answers
When you clone any record only the part on detail is cloned. So only the field on layout will be cloned. Even in Apex also it works like that see an Example :
I have a Contact c with FirstName = 'TestFirstName' , and LastName='TestLastName'
in My apex
Contact con = [Select LastName from Contact where LastName='TestLastName' limit 1];
Contact cloneofCon = c.clone(false);
insert cloneofCon;
now in above cloneofCon will not have first name as TestFirstName, first name will be null but if I do this
//queries first name also
Contact con = [Select LastName , Firstname from Contact where LastName='TestLastName' limit 1];
Contact cloneofCon = c.clone(false);
insert cloneofCon;
now i wil have firstname also
Now to solve your issue you can create a VFP and Overrride your Clone button , pass the id of your opportunity as query parameter , in page level action ( write a method in controller for this page level action) just fetch all the fields of opportunity and clone .
Let me know if any issues in it.
That's what I was thinking but hoping it was otherwise :-) Thanks for your reply!
Are you kidding me? Is this still the case? Why is it called clone if it does not clone but create a look-alike for the opportunity!?!?
I really hope that behaviour changed since 2011...