You need to sign in to do that
Don't have an account?

Error: Compile Error: Found punctuation symbol or operator '%' that isn't valid in Apex. at line 14 column 362
global class ABI_SFA_TAC_Removal_Batch implements Database.batchable<sObject> { // variable decleration. public String Query; /* Method Name: Start Description: This method is used to collect the TAC records ready for deletion. */ global Database.QueryLocator Start(Database.BatchableContext info) { // fetch TAC records ready for removal. String Query = 'SELECT ABI_SFA_Account_Removal__c,ABI_SFA_Account__c,ABI_SFA_RecordID__c,ABI_SFA_SHAREID__c, ABI_SFA_Type__c,ABI_SFA_User__c,ABI_SFA_Valid_Till__c,CreatedById,CreatedDate,CurrencyIsoCode,Id,IsDeleted,LastModifiedById,LastModifiedDate,Name,OwnerId,SystemModstamp FROM ABI_SFA_TerritoryAccountChange__c WHERE ABI_SFA_Account__r.name like '%Europromotion%' LIMIT 50000'; return Database.getQueryLocator(query); } /* Method Name: Execute Description: This method is used to process the TAC records that are passed from Start method. */ global void Execute(Database.BatchableContext info, List<ABI_SFA_TerritoryAccountChange__c> tacList) { if(tacList!=Null && tacList!=Empty){ System.debug('@@@inside IF block'); try { System.debug('@@@inside TRY block'); Database.DeleteResult[] TAC_Dels = Database.delete(tacList); } catch (DmlException e) { System.debug('@@@ The following exception has occurred: ' + e.getMessage()); ApexPages.addMessage(myMsg); ApexPages.Message myMsg = new ApexPages.Message(ApexPages.Severity.ERROR,<strong>string.valueof(e)</strong>); } } } /* Method Name: Finish Description: This method is used to notify all relevant stakeholders via Email. */ global void Finish(Database.BatchableContext info){ String Email; List<ID> tacERId = new List<ID>(); public void SendEmail() { for(TACEmailRecipients__c tacER: TACEmailRecipients__c.getAll().values());{ tacERId.add(tacER.Id); } EmailTemplate et=[Select id from EmailTemplate where name = 'TAC_Notification' limit 1]; Messaging.MassEmailMessage mail = new Messaging.MassEmailMessage(); mail.setTargetObjectIds(tacERId); mail.setSenderDisplayName('Acenture Support Team'); mail.setTemplateId(et.id); Messaging.sendEmail(new Messaging.MassEmailMessage[] { mail }); } } }
Change the query where condition like below ,
String Query = 'SELECT ABI_SFA_Account_Removal__c FROM ABI_SFA_TerritoryAccountChange__c WHERE ABI_SFA_Account__r.name like 'Europromotion%' LIMIT 50000';
Thanks,
SEKAR RAJ
All Answers
Change the query where condition like below ,
String Query = 'SELECT ABI_SFA_Account_Removal__c FROM ABI_SFA_TerritoryAccountChange__c WHERE ABI_SFA_Account__r.name like 'Europromotion%' LIMIT 50000';
Thanks,
SEKAR RAJ
IN Dynamic SOQL use of wildcards and the term 'Like' below
or using Apex Variables in case of SOQL use of wildcards and the term 'Like' below
Complete code