답변 4개
Thank you so much for your kind reply Abhinav,mukesh and suraj , i solved it by myselftrigger CheckProductTypeonOppLineItem_whenItIsCreated on OpportunityLineItem (before insert) { set<id> prdtIds=new set<id>(); set<id> oppIds=new set<id>(); for(OpportunityLineItem oli:Trigger.new ){ oppIds.add(oli.opportunityId); prdtIds.add(oli.product2Id); } opportunity opp=[select id ,product_type__c from opportunity where id in:oppIds]; product2 pd=[select id ,family from product2 where id in:prdtIds]; list<OpportunityLineItem> oliList=new list<OpportunityLineItem>(); for(OpportunityLineItem oli:Trigger.new ){ if(opp.product_type__c!=pd.family){ oli.addError('Product family does not match'); } }}