You need to sign in to do that
Don't have an account?
Azusfdc
Here i am unable create a new record in after insert trigger related to opportunity line item selected?
Trigger OpportunityPrdHisTrack on OpportunityLineItem (after insert){ if(Trigger.isafter && Trigger.isinsert) { HelperClass_one.opplineiteminsert(Trigger.new); } }
public class HelperClass_one{ public static void opplineiteminsert(List<OpportunityLineItem> opplinelist) { list<HistoryTracking__c> htlist=new list<HistoryTracking__c>(); for(OpportunityLineItem oppline:opplinelist) { HistoryTracking__c ht=new HistoryTracking__c(); ht.product__c=oppline.id; ht.Name=oppline.Name; ht.ProductDescription__c=oppline.Description; ht.ProductCode__c=oppline.ProductCode; htlist.add(ht); } insert htlist; } }
NOTE:- Record you are creating under OpportunityLineItem not under Opportunity. Please check record under OpportunityLineItem
Apex trigger OpportunityPrdHisTrack caused an unexpected exception, contact your administrator: OpportunityPrdHisTrack: execution of AfterInsert caused by: System.DmlException: Insert failed. First exception on row 0; first error: FIELD_INTEGRITY_EXCEPTION, Product: id value of incorrect type: 00k28000004CdQhAAK: [Product__c]: Class.HelperClass_one.opplineiteminsert: line 16, column 1
try below line let us know if this will help you