-
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

Fetching and Displaying Data in Salesforce Lightning Web Components: A Step-by-Step Guide Salesforce
Salesforce Lightning Web Components (LWC) is a framework provided by Salesforce to develop web applications easily. You know how to build cool things with building…

Accelerate Your Business Growth In 2023 With Salesforce Spring ‘23 Release
The Salesforce Spring ’23 Release is packed with new features and enhancements that will help businesses streamline their operations, improve collaboration, and drive growth. One of the…

What is Salesforce Financial Services?
If you work in the financial sector and you like Salesforce as much as we do, it’s likely you’ve heard of the Financial Services Cloud.…
Popular Salesforce Videos
How to Get Started on Your Salesforce Admin Certificate with Trailhead
In this video, Brad discusses how to get started with your Salesforce career using trailhead. He discusses how to create and validate your account, the…
Salesforce Marketing Cloud Connector for UiPath
This is a connector for Salesforce Marketing Cloud that allows you to work in the background with SFMC instance. watch this video and let us…
Salesforce Marketing Cloud Connect Complete Setup in Lightning
Cameron Robert demonstrates a complete end-to-end setup of Marketing Cloud Connect in Lightning view. Marketing Cloud Connect creates an integration between Salesforce CRM and Salesforce…