You need to sign in to do that
Don't have an account?
suji srinivasan
Hi, how to escape single quotes in soql.
I am getting error for my batch apex in soql as'illegal assignment of list to string'
how to resolve this?
global class UpdateAccountRating implements Database.Batchable<sObject>, Database.Stateful {
global Integer recordsProcessed = 0;
global Database.QueryLocator start(Database.BatchableContext bc) {
string query=[select Id,Rating,(select Id,StageName from Opportunities where StageName='Inprogress,Delivered,closedwon') From account where Rating!='client'];
return Database.getQueryLocator(query);
}
global Void execute(Database.BatchableContext bc, List<Account> Scope){
for(Account a :Scope){
a.Rating='client';
recordsProcessed = recordsProcessed + 1;
}
update Scope; }
global void finish(Database.BatchableContext bc){
System.debug(recordsProcessed + 'records processed. Shazam!');
AsyncApexJob job = [SELECT Id, Status, NumberOfErrors,JobItemsProcessed,TotalJobItems, CreatedBy.Email
FROM AsyncApexJob
WHERE Id = :bc.getJobId()];
}
}
thanks in advance
how to resolve this?
global class UpdateAccountRating implements Database.Batchable<sObject>, Database.Stateful {
global Integer recordsProcessed = 0;
global Database.QueryLocator start(Database.BatchableContext bc) {
string query=[select Id,Rating,(select Id,StageName from Opportunities where StageName='Inprogress,Delivered,closedwon') From account where Rating!='client'];
return Database.getQueryLocator(query);
}
global Void execute(Database.BatchableContext bc, List<Account> Scope){
for(Account a :Scope){
a.Rating='client';
recordsProcessed = recordsProcessed + 1;
}
update Scope; }
global void finish(Database.BatchableContext bc){
System.debug(recordsProcessed + 'records processed. Shazam!');
AsyncApexJob job = [SELECT Id, Status, NumberOfErrors,JobItemsProcessed,TotalJobItems, CreatedBy.Email
FROM AsyncApexJob
WHERE Id = :bc.getJobId()];
}
}
thanks in advance
Please follow below code:-
if you need any assistanse, Please let me know!!
Kindly mark my solution as the best answer if it helps you.
Thanks
Mukesh
All Answers
Can you try to replace the query as below.
If this solution helps, Please mark it as best answer.
Thanks,
Please follow below code:-
if you need any assistanse, Please let me know!!
Kindly mark my solution as the best answer if it helps you.
Thanks
Mukesh
Kindly mark my solution as the best answer if it helps you.
And create a new question for your new requirment
Thanks
Mukesh