-
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
Salesforce Visualforce – Select Record Using Radio Button
Hey! Here we are going to learn how to show the contacts related to account and select the account using radio button with Visualforce Page.…
Queueable Apex vs Batch Apex | Salesforce Developer Guide
Queueable Apex Apex processes that run for a long time, such as extensive database operations or external web service callouts, can be run asynchronously by…
Popular Salesforce Videos
How Users Set Up Einstein Activity Capture | Salesforce Tutorial
Say goodbye to busy work. Say hello to smarter selling. When you connect your email and calendar to Salesforce with Einstein Activity Capture, their email…
DreamTX Welcome Day 2 | Dreamforce 2020 | Salesforce
If you missed DreamTX DAY 2, then live this amazing experience here, we have covered it all for you. See the power of Customer 360,…
What are Queues in Salesforce? | How to create queues and assign records to it in Salesforce?
This video explains Queues in Salesforce by dividing this topic into 5 basic points, which are: 1. What purpose do queues solve? 2. What are…