You need to sign in to do that
Don't have an account?
ruchika Nayyar
trigger code for this?
Write a trigger on Opportunity, when an Opportunity will be insert an Opportunity Line Item should be insert by default with any of the Product associated with Opportunity
Hi Ruchika,
Please add trigger like below:
trigger opportunityTrigger on Opportunity (After Insert){
List<OpportunityLineItem> oliList = new List<OpportunityLineItem>();
for(Opportunity Op: Trigger.New){
if(op.product != null ){
OpportunityLineItem oli = new OpportunityLineItem();
oli.Product = op.product;
oli.opportunity = op.id
oliList.add(oli);
}
}
if(oliList != null && oliList.size() > 0)
insert oliList;
}
Add / Remove field as per your requirements.
Let me know if you still found issues.
Thanks,
Gaurav
Email: gauravgarg.nmims@gmail.com
Skype: gaurav62990
From where we get opportunity line item in opportunity field?? Please help me out
As per salesfroce standard Opportunity Data structure, Product field is not available on Opportunity. Are you trying to add this field addionationally. If yes. please replace this line:
oli.Product = op.product;
with below line:
oli.Product2Id = op.product_id__c;
Thanks,
Gaurav
Email: gauravgarg.nmims@gmail.com
Skype: gaurav62990