+ Start a Discussion
SalesforceCrm AccountCRMSalesforceCrm AccountCRM 

Compile Error: expecting a right parentheses, found ',' at line 22 column 298

Hello ,
The System throws an Error as :
Compile Error: expecting a right parentheses, found ',' at line 22 column 298
When i use this query
 
Database.getQueryLocator([Select id, Contract_Name__c , EndDate ,Contact_Email__c, Contract_End_Date_2__c, Owner.Email, Owner.Manager.Email ,Account.Owner.Email,Account.Owner.Manager.Email  FROM Contract  WHERE Id IN: setContractIds AND Renewal_Status__c IN :('Pushed Forward To Next Quarter','In Pipe') AND Next_Quarter_Renewal_Status__c IN :('Renewed','Renewal lost’)]);
Any help very much appreciated.




 
RatanRatan
remove colon 
Database.getQueryLocator([Select id, Contract_Name__c , EndDate ,Contact_Email__c, Contract_End_Date_2__c, Owner.Email, Owner.Manager.Email ,Account.Owner.Email,Account.Owner.Manager.Email  FROM Contract  WHERE Id IN setContractIds AND Renewal_Status__c IN ('Pushed Forward To Next Quarter','In Pipe') AND Next_Quarter_Renewal_Status__c IN ('Renewed','Renewal lost’)]);
Amit Chaudhary 8Amit Chaudhary 8
PLease try below query and let us know if this will help you
atabase.getQueryLocator([Select id, Contract_Name__c , EndDate ,Contact_Email__c, Contract_End_Date_2__c, Owner.Email, Owner.Manager.Email ,Account.Owner.Email,Account.Owner.Manager.Email  FROM Contract  WHERE Id IN setContractIds AND Renewal_Status__c IN ('Pushed Forward To Next Quarter','In Pipe') AND Next_Quarter_Renewal_Status__c IN ('Renewed','Renewal lost')]);

 
SalesforceCrm AccountCRMSalesforceCrm AccountCRM
@Ratan ,@Amit Chaudhary 8 :Thanks for the response.When i remove return from the query ,the system throws an error as
Compile Error: Non-void method might not return a value or might have statement after a return statement. at line 22 column 8
When i add
return.Database.getQueryLocator([Select id, Contract_Name__c , EndDate ,Contact_Email__c, Contract_End_Date_2__c, Owner.Email, Owner.Manager.Email ,Account.Owner.Email,Account.Owner.Manager.Email  FROM Contract  WHERE Id IN setContractIds AND Renewal_Status__c IN ('Pushed Forward To Next Quarter','In Pipe') AND Next_Quarter_Renewal_Status__c IN ('Renewed','Renewal lost’)]);
The code gets saved ,but the email notification is not sent.



 
RatanRatan
you code should be like
 
return Database.getQueryLocator([Select id, Contract_Name__c , EndDate ,Contact_Email__c, Contract_End_Date_2__c, Owner.Email, Owner.Manager.Email ,Account.Owner.Email,Account.Owner.Manager.Email  FROM Contract  WHERE Id IN setContractIds AND Renewal_Status__c IN ('Pushed Forward To Next Quarter','In Pipe') AND Next_Quarter_Renewal_Status__c IN ('Renewed','Renewal lost’)]);

after return, there should be a space.. 
 
Amit Chaudhary 8Amit Chaudhary 8
Please post your full method so that we can help you
SalesforceCrm AccountCRMSalesforceCrm AccountCRM
@Amit Chaudhary 8 :When i use the below query ,i get the email notification as per the requirement :
return Database.getQueryLocator('Select id, Contract_Name__c , EndDate ,Contact_Email__c, Contract_End_Date_2__c ,ownerId,Owner.Email, Account.Owner.Email FROM Contract WHERE Id IN: setContractIds');
When i use the below query ,the code gets saved but im not getting the email notification .
return Database.getQueryLocator([Select id, Contract_Name__c , EndDate ,Contact_Email__c, Contract_End_Date_2__c, Owner.Email, Owner.Manager.Email ,Account.Owner.Email,Account.Owner.Manager.Email,Renewal_Status__c,Next_Quarter_Renewal_Status__c FROM Contract WHERE Id IN: setContractIds AND Renewal_Status__c IN ('Pushed Forward To Next Quarter','In Pipe') AND Next_Quarter_Renewal_Status__c IN ('Renewed','Renewal lost')]);
Based on the scenario here is batch class written.



 
global class NotificationEmailtoOwner implements Database.Batchable < sObject > 
{
    global Database.QueryLocator start(Database.BatchableContext bc) 
    {
        
        Date ed = Date.today().addDays(90);
        System.debug(Date.today().addDays(90));
        
        set<Id> setContractIds = new set<Id>();
        
        for(Contract_role__c objContract: [SELECT  Contract__c FROM Contract_role__c WHERE Role__c = 'Subscription Administrator' AND Contract__r.EndDate =: ed ])
         {
           setContractIds.add(objContract.Contract__c);
         }
        
 
        //return Database.getQueryLocator('Select  id, Contract_Name__c , EndDate ,Contact_Email__c, Contract_End_Date_2__c ,ownerId,Owner.Email, Account.Owner.Email  FROM Contract  WHERE Id IN: setContractIds');

       return Database.getQueryLocator([Select id, Contract_Name__c , EndDate ,Contact_Email__c, Contract_End_Date_2__c, Owner.Email, Owner.Manager.Email ,Account.Owner.Email,Account.Owner.Manager.Email,Renewal_Status__c,Next_Quarter_Renewal_Status__c  FROM Contract WHERE Id IN: setContractIds AND Renewal_Status__c IN ('Pushed Forward To Next Quarter','In Pipe') AND Next_Quarter_Renewal_Status__c IN ('Renewed','Renewal lost')]);
    }

    global void execute(Database.BatchableContext bc, List < Contract > recs) 
    {
        List < Messaging.SingleEmailMessage > mailList = new List < Messaging.SingleEmailMessage > ();
        
        for (Contract c: recs) 
        {
         
        
            if (c.Contact_Email__c!= null) 
            {
                List < String > toAddresses = new List < String > ();
                List < String > ccAddresses = new List < String > ();
                Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
                //toAddresses.add(c.Contact_Email__c);
                toAddresses.add(c.Account.Owner.Email); 
                ccAddresses.add(c.Owner.Email);
                mail.setToAddresses(toAddresses);
                mail.setCCAddresses(ccAddresses);
                mail.setSubject('Notification Before 90 Days of Contract End Date to the Account Owner');
                String messageBody = '<html><body>Hello , The Contract named' +  c.Contract_Name__c   + ',
 Will get Expired within 90 Days . 
Kindly take approriate action to inform the customer.

<b>Regards,</b>
ADP SQL</body></html>';
                mail.setHtmlBody(messageBody);
                mailList.add(mail);
               
            }
        }
        Messaging.sendEmail(mailList);
    }

    global void finish(Database.BatchableContext bc) {}
}
Any help very much appreciated.