-
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
Make your Salesforce life easy with Salesforce advanced code searcher and ORGanizer for Salesforce
Salesforce advanced code searcher and ORGanizer for Salesforce, both are google chrome's extensions which adds an extra features to your salesforce org. Salesforce advanced code…
Display Custom Roll-up Summary on Account | Salesforce Developer Guide
In this blog, I would like you to share, how to display a custom roll-up summary on the account. Before moving to code first create…
Decorators in Salesforce
Salesforce is the best-known CRM in today’s world. It provides many functionalities that make our lives easier. Lightning web components and Apex classes are one…
Popular Salesforce Videos
Salesforce Live Executive Experience: UK and Ireland 2021
At Salesforce Live Executive Experience we welcomed guests in-person and virtually to enjoy enlightening content, much missed networking and a performance from Jools Holland. The…
How to Prepare for a Salesforce Job Interview
Watch this video to learn how to Prepare for a Salesforce Job Interview.
Build Your First Custom App On Salesforce
Lightning App Builder makes it super simple to quickly assemble apps using just declarative drag and drop features. This video covers how to upgrade a…