-
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
Future Methods in Salesforce: An Overview
Future methods are is a set of code that runs in the background. It is basically an asynchronous process. Don’t forget to check out: Asynchronous…
Implementing Salesforce Path in Lightning
Salesforce developers use Salesforce Path as a successful visualization tool that helps users as a guide along any particular path to reach a final goal.…
Top 5 Best Salesforce Integration Practices in 2021
Adopting Salesforce integration is always beneficial for automating and scaling the businesses efficiently. The whole idea of integrating data might look easy, but there’s a catch. To…
Popular Salesforce Videos
Easy Salesforce Lightning Experience Tricks for Admins
Learn how to enhance the screens for your end users by leveraging Related List - Quick Links, Report Charts and dynamic filters to show the…
How to Use a Phone in Salesforce with Dialer for Essentials | Salesforce Essentials
Unify your team with a single company phone number. Lightning Dialer for Essentials lets you and your team close deals and take support calls right…
Salesforce Acquires Slack
When Salesforce bought Slack earlier this week for $27.7 billion, it was in some ways the end of a startup fairytale. Slack was the living…