+ Start a Discussion
Srinivas223Srinivas223 

Can anyone tell me what is wrong here

for(REVVY__MnContract__c contract: NewMap.values()) {              
                     if (oldMap.get(contract.Id).ContractStage__c == 'Signature|Completed' && contract.ContractStage__c == 'Booked|In Effect') {
                         if(contract.REVVY__Opportunity__c != null){
                           system.debug('00000000' + contract.REVVY__Opportunity__r.owner );
                        
                           mapContracts.put(contract.REVVY__Opportunity__c, contract);
                         }
                     
                     }
                } 
            // the method is to send an email when MnContract life cycle is activated. We do not activate bulk records at a time
            // so not considering bulk here
          
            acRels = new list<Aircraft_Relationship__c>();              
          
           user OpptyUser = new user();
            if(!mapContracts.isEmpty()) {
            
            Opp = [select id, name,(select id,Date_Ordered__c, Aircraft__r.name, Opportunity__r.name,Aircraft_User__r.name from A_C_Relationships__r),ownerid from opportunity where id =: (mapContracts.keyset())[0]];
           // system.debug('-----0000----' + ContractOpptyIDs);
                   for(Aircraft_Relationship__c acRel: opp.A_C_Relationships__r){
                   acRels.add(acRel);
                  
                }
                system.debug('the no of ac Rel associated to the opp ' + acRelsize.size());
            }
            if(Opp != null){
                OpptyUser = [select id, name, email from User where  id = opp.ownerid] ;
                EmailTemplate emailTemplates = [select id,name,subject from EmailTemplate 
                where name = 'Contract Stage Activate Notification' and isActive = true and 
                TemplateType = 'visualforce' limit 1];                                            
                system.debug('00000000'+ emailTemplates );

the error message is Unexpected token 'opp.ownerid'.
I appreciate your help.
Thank you
Raj VakatiRaj Vakati
Change it as shown below line number 28 

 
OpptyUser = [select id, name, email from User where  id = :opp.ownerid] ;

 
Raj VakatiRaj Vakati
for(REVVY__MnContract__c contract: NewMap.values()) {              
                     if (oldMap.get(contract.Id).ContractStage__c == 'Signature|Completed' && contract.ContractStage__c == 'Booked|In Effect') {
                         if(contract.REVVY__Opportunity__c != null){
                           system.debug('00000000' + contract.REVVY__Opportunity__r.owner );
                        
                           mapContracts.put(contract.REVVY__Opportunity__c, contract);
                         }
                     
                     }
                } 
            // the method is to send an email when MnContract life cycle is activated. We do not activate bulk records at a time
            // so not considering bulk here
          
            acRels = new list<Aircraft_Relationship__c>();              
          
           user OpptyUser = new user();
            if(!mapContracts.isEmpty()) {
            
            Opp = [select id, name,(select id,Date_Ordered__c, Aircraft__r.name, Opportunity__r.name,Aircraft_User__r.name from A_C_Relationships__r),ownerid from opportunity where id =: (mapContracts.keyset())[0]];
           // system.debug('-----0000----' + ContractOpptyIDs);
                   for(Aircraft_Relationship__c acRel: opp.A_C_Relationships__r){
                   acRels.add(acRel);
                  
                }
                system.debug('the no of ac Rel associated to the opp ' + acRelsize.size());
            }
            if(Opp != null){
                OpptyUser = [select id, name, email from User where  id = :opp.ownerid] ;
                EmailTemplate emailTemplates = [select id,name,subject from EmailTemplate 
                where name = 'Contract Stage Activate Notification' and isActive = true and 
                TemplateType = 'visualforce' limit 1];                                            
                system.debug('00000000'+ emailTemplates );

 
sfdcMonkey.comsfdcMonkey.com
hi update your line number 28 : 
 OpptyUser = [select id, name, email from User where  id = : opp.ownerid] ;

Thanks , let us know if it helps you 
sfdcMonkey.comsfdcMonkey.com
you got his error because you are missing colon (:)  to bind variable in SOQL 

SOQL and SOSL statements in Apex can reference Apex code variables and expressions if they’re preceded by a colon (:).
Srinivas223Srinivas223
tried that way but no luck. Thank you
Raj VakatiRaj Vakati
Can you share the complete code  
sfdcMonkey.comsfdcMonkey.com
this is only the reason for your error, do one thing copy your existing apex code and close the class tab and reopen class again and paste your code and try to save it again