You need to sign in to do that
Don't have an account?
Test Method for Approval process
Hi,
I wrote trigger on Lead for auto firing of 'Submit for Approval' request once the Lead is Qualified, its working fine in Sandbox , how to write test method for this trigger, Can anybody send the sample test methods.
Thanks In Advance....
______________________________________________________________________________
trigger trigger_auto_request on Lead (after insert,after update) {
{
for (Integer i = 0; i < Trigger.new.size(); i++)
{
if (Trigger.new[i].status =='Qualified' )
{
Approval.ProcessSubmitRequest req = new Approval.ProcessSubmitRequest();
req.setComments('Submitted for approval. Please approve.');
req.setObjectId(Trigger.new[i].Id);
Approval.ProcessResult result = Approval.process(req);
System.debug('Submitted for approval successfully: '+result.isSuccess());
}
}
}
}
_____________________________________________________________________________________
Mahesh...........
You only need create the lead records with the status =='Qualified' and then you can check the request status in Process Instance object.