-
Error: Only variable references are allowed in dynamic SOQL/SOSL.
Hi all, Got stuck in Batch classes not able to execute, getting system.queryexception - Only variable references are allowed in dynamic SOQL/SOSL.
global class SearchAndReplace implements Database.Batchable<sobject>{
global String Query;
global List<id>allObjIds ;
global SearchAndReplace(List<id>allObjectIds){
allObjIds=allObjectIds;
}
global Database.QueryLocator Start(Database.BatchableContext BC){
query='SELECT Id,Name FROM Sobject WHERE Id in:'+allObjIds;
return Database.getQueryLocator(query);
}
global void execute (Database.BatchableContext BC,List<Account>scope){
for(Account obj:scope){
obj.Name='Algoworks';
}
update scope;
}
global void finish (Database.BatchableContext BC){
}
}
Log In to reply.
Popular Salesforce Blogs
These 5 Steps Will Help You Improve the Health of Your Salesforce Data
Companies struggling to maintain the quality health of their data should not expect the deluge of data to slow down anytime soon. In fact, the…
Real Time Access To External Data Using Salesforce Lightning Connect
Salesforce as we all know is the most renowned CRM-in-the-cloud of this era. In addition to endless top features, another vital aspect is its ability…
Manage Ideas in Your Salesforce Community With IdeasPro
Ideas are the most powerful force imaginable. And you never know when you could stumble upon one. In the previous blog post, we talked about online…
Popular Salesforce Videos
Process Builder In Salesforce | Tutorial Video
Do you want to create a record for any object from a workflow? Do you want to call your Apex class from a workflow? Do…
Getting Turn by Turn Directions Between Scheduled Events | Salesforce Maps Mobile
Watch this video to learn how to get turn-by-turn directions between scheduled events in Salesforce Maps Mobile. 00:00 - Introduction 00:19 - Access your Schedule…
Event Driven Development on Salesforce | All About Event in Salesforce
In this session, we will talk about Event-Driven Development in Salesforce. Let’s take a look into the many ways events have changed the way we…