You need to sign in to do that
Don't have an account?
Soubhagya Ranjan 2
Error in Batch Class
I want to delete records having status as rejected through batch class .
please check the below code and let me know the correct code
global class batchdeleteloan implements Database.batchable<sobject>{
global final String Query;
global batchdeleteloan (String q)
{
Query=q;
}
global Database.QueryLocator start(Database.BatchableContext BC)
{
return Database.getQueryLocator(query);
}
global void execute(Database.BatchableContext BC,List<SObject> scope)
{
List <List<Laon_Application__c> > loanList = new list<List<Laon_Application__c> >();
for(List<Laon_Application__c> l : scope)
{
List<Laon_Application__c> la = (List<Laon_Application__c>)l;
If(l.Status__c = 'Rejected'){
LoanList.add(la);
}
}
Delete LoanList;
}
global void finish(Database.BatchableContext BC){
}
}
please check the below code and let me know the correct code
global class batchdeleteloan implements Database.batchable<sobject>{
global final String Query;
global batchdeleteloan (String q)
{
Query=q;
}
global Database.QueryLocator start(Database.BatchableContext BC)
{
return Database.getQueryLocator(query);
}
global void execute(Database.BatchableContext BC,List<SObject> scope)
{
List <List<Laon_Application__c> > loanList = new list<List<Laon_Application__c> >();
for(List<Laon_Application__c> l : scope)
{
List<Laon_Application__c> la = (List<Laon_Application__c>)l;
If(l.Status__c = 'Rejected'){
LoanList.add(la);
}
}
Delete LoanList;
}
global void finish(Database.BatchableContext BC){
}
}
For more knowledge about batch see the link. (https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_batch_interface.htm)
1) http://amitsalesforce.blogspot.com/search/label/Batch%20Job
Please update your code like below
Let us know if this will help you
still getting error : Initial term of field expression must be a concrete SObject: List<Laon_Application__c> at line 20 column 16
while running in developer console it is showing constructer not defiend .
Use below code for the batch class.
For executing the batch from Developer console use below code.
Let me know if this helps :)
Thanks!
Amit Singh
I did one small system issue in below line Please update code like below
Please try below code :-
NOTE :- To execute the above batch job you need to pass query in your constructor like below
Let us know if this will help you