You need to sign in to do that
Don't have an account?
b.gonzalez
Compile Error: Variable does not exist
I am modifying an existing triggger and I am new to development. Need your help with the following error: Error: Compile Error: Variable does not exist: opp.Distributor_Performing_Integration__c at line 6 column 66
Thanks!
Beth
trigger CMR_OpportunityLineItemUpdated on OpportunityLineItem (after insert, after update, after delete, after undelete,before update, before insert) { //Added before insert and before update events for Case 00076809 //Added if condition for Case 00076809 Opportunity I = trigger.new [0]; if(I.RecordType.Name =='NewBDChannelOppRecordType'){ if(I.RecordType.Name =='DesignChannelOpportunityRecordType'&&opp.Distributor_Performing_Integration__c==false&&opp.Distributor_Performing_Integration__c==true){ if(trigger.IsAfter){ string OpportunityId = ''; if(trigger.isDelete) { OpportunityId = trigger.old[0].OpportunityId; } else { OpportunityId = trigger.new[0].OpportunityId; } Opportunity opp = new Opportunity(Id=OpportunityId); opp.CSG__c = false; opp.LMG__c = false; opp.NXN__c = false; opp.SPG__c = false; opp.SSG__c = false; opp.STI__c = false; opp.SIG__c = false; opp.EPG__c = false; List<OpportunityLineItem> prods = [Select PricebookEntry.Product2.Oracle_LOB__c From OpportunityLineItem Where PricebookEntry.IsActive = True And PricebookEntry.IsDeleted = False And PricebookEntry.Product2.IsActive = True And PricebookEntry.Product2.IsDeleted = False And OpportunityId = :OpportunityId]; for(OpportunityLineItem oli:prods) { Product2 p2 = oli.PricebookEntry.Product2; if(p2.Oracle_LOB__c == 'CSG') { opp.CSG__c = true; } else if(p2.Oracle_LOB__c == 'LMG') { opp.LMG__c = true; } else if(p2.Oracle_LOB__c == 'NXN') { opp.NXN__c = true; } else if(p2.Oracle_LOB__c == 'SPG') { opp.SPG__c = true; } else if(p2.Oracle_LOB__c == 'SSG') { opp.SSG__c = true; } else if(p2.Oracle_LOB__c == 'STI') { opp.STI__c = true; } else if(p2.Oracle_LOB__c == 'SIG') { opp.SIG__c = true; } else if(p2.Oracle_LOB__c == 'EPG') { opp.EPG__c = true; } } update opp; } // Added for Case 00076809 if(trigger.IsBefore){ Set<String> products = new Set<String>{'SPG_SWITCH_TEST', 'SSG_ROUTER_TEST','PRF1-105XXC','PRF3-105XXC'}; Map<Id,OpportunityLineItem> oliMap = new Map<Id,OpportunityLineItem>([Select Id, PricebookEntry.Product2.Name,PricebookEntry.Product2Id, Discount__c from OpportunityLineItem where Id in:trigger.New and (PricebookEntry.Product2.name in: products or PricebookEntry.Product2.Name like '%-MO-%')]); system.debug('**oliMap**'+oliMap ); for(OpportunityLineItem oli: trigger.new){ system.debug('**inside for**' ); if(oliMap!= null && oliMap.get(oli.Id)!=null){ system.debug('**inside if**' ); oli.Discount__c = 0; } } } } } }
Thanks!
Beth
All Answers
Beth
you need to revist your logic. you might have to do the following forst before doing any logic.
string OpportunityId = '';
09 if(trigger.isDelete) {
10 OpportunityId = trigger.old[0].OpportunityId;
11 } else {
12 OpportunityId = trigger.new[0].OpportunityId;
13 }
14 Opportunity opp = new Opportunity(Id=OpportunityId);
Okay, thank you!
Beth
list<String> acclist=new list<String>();
for(Account b:Trigger.New)
{
acclist.add(b.Name);
}
list<Contact> contact=[select LastName from Contact where LastName in:acclist];
delete contact;
}
i got error for this code like variable does not exist Name