You need to sign in to do that
Don't have an account?
SFDC12
clone scenario
Hi everyone Iam very new to salesforce trying to clone opportunity and opportunityLineitem but unable to see the result correctly,Below is the code which i have tried..
class:
public class cloneoppandopplineitem {
public static void oppmethod(List<id>oppid){
opportunity opp=[select id,name,stageName,closeDate from opportunity where id=:oppid];
opportunity oppinse=opp.clone(false);
system.debug('1-->'+oppinse);
oppinse.StageName='prospecting';
insert oppinse;
system.debug('2-->'+oppinse);
opportunityLineItem oli=[select Product2.name,opportunityId, Product2Id,Quantity from OpportunityLineItem where opportunityId=:oppid];
system.debug('3-->'+oli);
opportunityLineItem ol=oli.clone(false);
ol.OpportunityId=oppinse.id;
insert ol;
system.debug('4-->'+ol);
}
}
class:
public class cloneoppandopplineitem {
public static void oppmethod(List<id>oppid){
opportunity opp=[select id,name,stageName,closeDate from opportunity where id=:oppid];
opportunity oppinse=opp.clone(false);
system.debug('1-->'+oppinse);
oppinse.StageName='prospecting';
insert oppinse;
system.debug('2-->'+oppinse);
opportunityLineItem oli=[select Product2.name,opportunityId, Product2Id,Quantity from OpportunityLineItem where opportunityId=:oppid];
system.debug('3-->'+oli);
opportunityLineItem ol=oli.clone(false);
ol.OpportunityId=oppinse.id;
insert ol;
system.debug('4-->'+ol);
}
}
https://developer.salesforce.com/forums/?id=906F00000008oEUIAY
If it helps mark it as best.
Thanks!
All Answers
You can use standard button "Clone With Related", and you can choose Opprtunity Line Item from There.
if you need any assistanse, Please let me know!!
Kindly mark my solution as the best answer if it helps you.
Thanks
Mukesh
https://developer.salesforce.com/forums/?id=906F00000008oEUIAY
If it helps mark it as best.
Thanks!