-
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
Tips For Choosing The Best Salesforce Consulting Partner
Salesforce is considered as a customer relationship management service, which brings in customers and companies together. Therefore, it is the juggernaut of the CRM platform…
Salesforce Commerce Cloud Implementation
Salesforce is a globally trusted and most popular cloud-based platform that offers a wide range of digital products to businesses to increase their potential, acquire…
Salesforce Marketing Cloud Hacks You Must Try
For any Marketing Cloud professional, it is important to know the ins and outs of the product so it can be used to its full…
Popular Salesforce Videos
Salesforce - How to Create and Debug Process Builders
Check out this video on how to debug Process Builders. Once you really get into building processes in Salesforce in can be confusing as to…
How to Reference Custom Metadata Types to Optimize Salesforce Account Records Using Salesforce Flow
Salesforce Account Region Allocation using Custom Metadata Types and Salesforce Flow This video walks through an example of how you can reference Custom metadata Types…
COVID 19 Tracker in Salesforce Lightning Aura Component
In this video, we are developing a lightning Component to track the current pandemic COVID19 Stats Tracker which shows the current situation of all countries…