You need to sign in to do that
Don't have an account?

batch not executing, called from trigger
I want check for duplicate id getting inserted in account, I have called batch class from trigger.
trigger id with its name need to pass to batch class, and chek against all account if the record with name already existing.
But my batch not executing, below is my code
global class DuplicateAccount implements Database.Batchable<sObject>
{
Public integer leadcount{get;set;}
global String Query;
set<id> ACCTIDS=new set<id>();
global account []A {get;set;}
list<String> MainAccounts = new list<String >();
global DuplicateAccount (list<string> listAccounts)
{
system.debug('daaaaaa'+listAccounts);
MainAccounts = listAccounts;
system.debug('mmmmmmmmmaaaaaaaaaaaaa'+MainAccounts );
}
global Database.QueryLocator start(Database.BatchableContext BC)
{ system.debug('ffffffffffffff');
query='SELECT Id FROM account WHERE name IN: MainAccounts';
system.debug('mmmmmmmmmmmmmmmmmmmm'+MainAccounts);
return Database.getQueryLocator(query);
}
global void execute(Database.BatchableContext BC, List<Account> scope)
{system.debug('aaaaaaaaaaaaaaaaaaaa');
Account []aname=[select name from account where name in: MainAccounts ];
for(account ac: scope){
if(ac.name==aname[0].name){system.debug('dssdcsdc');}
}
}
global void finish(Database.BatchableContext BC)
{
//Send an email to the User after your batch completes
Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
String[] toAddresses = new String[] {'sforce2009@gmail.com'};
mail.setToAddresses(toAddresses);
mail.setSubject('Apex Batch Job is done');
mail.setPlainTextBody('The batch Apex job processed ');
Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
}
}
And also ensure your trigger is active.
No error.
Just execute method is not calling.
Trigger is active.
Could you post the triggers code from where you are calling this batch?