-
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 for Nonprofits: Problems, Use Cases, and Tips
Each NGO has an impactful mission that helps transform the society we live in. However, the path to success holds a lot of difficulties that…
Iteration Components Used In Salesforce VisualForce Pages
Iteration Components Used In Salesforce Visualforce Pages Iteration Components allow you to display the output of content on the page in the form of a…
Bypassing the “Number of Iterations Exceeded” Error in Salesforce Flows with Platform Events
Elements Limit in Flows Flows in Salesforce are great, but there are some limits that can make working with them very frustrating. One of those…
Popular Salesforce Videos
What is Dreamforce? | Salesforce Explained
Dreamforce has been coined “the world’s largest tech conference” and is a massive streaming moment on Salesforce+, but what actually takes place at this iconic…
Simplify Salesforce Development using CLI and VSCode Tasks
The Salesforce CLI is a powerful command-line interface that simplifies development and builds automation when working with your Salesforce org. Typing commands can be monotonous…
Salesforce Platform Quick Tip: How to Access Popular Items in a Single Click
Want to get to the things you use most with fewer clicks? Trailblazer and Senior Salesforce Developer, Ellie Matthewman shows us how to use favourites…