-
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
The Best 7 Salesforce 2020 Trends For Your Company
As businesses continue to move business-critical apps to the demand for services has exponentially risen. Being an undisputed leader in the services segment, this year…
5 Ways To Leverage Salesforce Effectively To Fuel Your Financial Services
Salesforce is changing the face of the B2B financial services industry. Firms seem to be winning by leveraging Salesforce to increase customer engagement, personalize offers…
Why Bulk Automation Matters in Growing Salesforce Orgs
Salesforce is designed to scale with business growth. But as orgs expand, so does the effort required to manage them. More users, more objects, more…
Popular Salesforce Videos
What are Salesforce Editions and Pricing in Details?
Salesforce Editions and Pricing - Salesforce are providing four types of licenses Essentials, Professionals, Enterprise and Unlimited. Watch the video and if you have any…
Three Quick Wins With Pardot | Salesforce
Discover the full suite of B2B marketing automation tools to create meaningful connections, generate more pipeline, and empower sales teams to close more deals. See…
Salesforce Territory Management
This short video gets you started in setting up sales territories for your team. With sales territories, you can keep track of which sales reps…