6 件の回答
Hi @Jyoti Bhosale,
Insert DML will not accept the ID field. Also, you need to use the Opportunity Product (API Name: OpportunityLineItem) standard object instead of Product2.
You can use the below code.
public static void createProductMethod(List<Opportunity> opportunities) {
List<OpportunityLineItem> productList = new List<OpportunityLineItem>();
for (Opportunity opp : opportunities) {
OpportunityLineItem product = new OpportunityLineItem(Opportunity = opp.Id, Name = opp.List_Of_Products__c);
productList.add(product);
}
insert productList;
}
Regards,
Dinakar K