-
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
Introduction to Salesforce: What is Salesforce and Why is it Popular?
What is Salesforce? Imagine having a platform that allows your business to manage everything in one place—customer relationships, sales, marketing, support, and more. That’s Salesforce,…
What is the Salesforce Experience Cloud? | The Ultimate Guide
Salesforce is a cloud-based customer relationship management (CRM) platform that provides businesses with a suite of tools to manage customer data and interactions. One of…
Queueable Apex in Salesforce - Concept to Implementations
INTRODUCTION Queueable Apex is an apex code that runs Asynchronously like a future method. Here the term Asynchronous means running in the background . Queueable…
Popular Salesforce Videos
How To Use Salesforce Marketing Cloud Automation Studio
In this video, you will learn how to use Salesforce Marketing Cloud Automation Studio which will help in automating various processes. The following points will…
What it Means to be a Salesforce Developer
In this video, Salesforce with Polina describes what it means to be a Salesforce Developer. She goes on to describe the different types of Salesforce…
Is Generative AI Is The New Future Of Salesforce?
Every industry, whether IT, Finance, or health, is moving towards AI? There has been a lot of talk about Generative AI and how it can…