-
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 Security Model - Explained
Salesforce Security Model Salesforce Security Model Classification. Security in Salesforce is broadly classified in two sorts. They are System Level Security. Application Level Security. System…

Learn All About Apex in Salesforce | The Developer Guide
What is Apex in Salesforce? Apex is a strongly typed, object-oriented programming language that allows developers to run flow and transaction control statements on Salesforce…

8 New Features of Salesforce Financial Services Cloud
Salesforce has recently launched new features in Financial Services cloud to drive customer engagement across wealth management, banking, and insurance. Salesforce designed Financial Cloud Software to revolutionize…
Popular Salesforce Videos
Salesforce Integration Crash Course | The Ultimate Guide to Salesforce Integrations
In these 100 minutes, you are going to learn almost all the integration concepts with the help of 2 projects. You will learn about API,…
Salesforce Account-Based Marketing Demo
Salesforce Account-Based Marketing is a partnership aligning Marketing, Sales, and Service around a single view of your top accounts. A partnership which reesults in long…
What are Cross Object Formula fields in Salesforce?
In this video, Cross Object Formula Fields in Salesforce is explained by dividing this topic into 4 basic points, which are: 1. What is Cross…