You need to sign in to do that
Don't have an account?
Trigger Compile Error trying to update multiple fields on OppLineItem with data from Product2
I get the following error:
Error: Compile Error: Variable does not exist: oli.sbu_abbr__c at line 21 column 7 |
When I try to save the trigger code below.
trigger oppLineItem_prod_data_trigger on OpportunityLineItem (before insert, before update) { Set<Id> pbeIds = new Set<Id>(); for (OpportunityLineItem oli : Trigger.new) pbeIds.add(oli.pricebookentryid); Map<Id, PricebookEntry> entries = new Map<Id, PricebookEntry>( [Select product2.sbu_abbr__c, product2.bu_abbr__c From PricebookEntry where id in :pbeIds]); . for (OpportunityLineItem oli : Trigger.new) oli.bu_abbr__c = entries.get(oli.pricebookEntryId).product2.bu_abbr__c; oli.sbu_abbr__c = entries.get(oli.pricebookEntryId).product2.sbu_abbr__c; }
Can someone tell me what I'm doing wrong.
Thanks.
I beleive this is a simple syntax error: you are missing the "{" when starting your for loop...
It should be...