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

Not able to Call future method in Test Class
Hi All,
Not able to call future method in test class. while inserting test data into the test class. test class is not calling the future method. find the below code
Public class SampleClass{
Public static void UpdatingRecordFields(ID AccountID){
//logic
//logic
CallFutureMethod(AccountID)
}
@future
Public Static void CallFutureMethod(ID AccountID){
//Calling Approval Process
Approval.ProcessSubmitRequest req1 = new Approval.ProcessSubmitRequest();
req1.setObjectId(AccountID);
req1.setProcessDefinitionNameOrId('Manager_Approval_Process_API');
Approval.ProcessResult result = Approval.process(req1); //(Here approval process meeting the crtiria but it showing this error) FATAL_ERROR|System.DmlException: Process failed. First exception on row 0; first error: NO_APPLICABLE_PROCESS, No applicable approval process was found.: []
}
}
Not able to call future method in test class. while inserting test data into the test class. test class is not calling the future method. find the below code
Public class SampleClass{
Public static void UpdatingRecordFields(ID AccountID){
//logic
//logic
CallFutureMethod(AccountID)
}
@future
Public Static void CallFutureMethod(ID AccountID){
//Calling Approval Process
Approval.ProcessSubmitRequest req1 = new Approval.ProcessSubmitRequest();
req1.setObjectId(AccountID);
req1.setProcessDefinitionNameOrId('Manager_Approval_Process_API');
Approval.ProcessResult result = Approval.process(req1); //(Here approval process meeting the crtiria but it showing this error) FATAL_ERROR|System.DmlException: Process failed. First exception on row 0; first error: NO_APPLICABLE_PROCESS, No applicable approval process was found.: []
}
}
Future methods is a static method and need to be called using Class name and it should be within test.startTest() and test.StopTest method call. For eg.
Class Name: MYFutureClass
Future Method: myFutureMethod
then we need to call future method like this:
Please try using below code:
Public class SampleClass{
Public static void UpdatingRecordFields(ID AccountID){
//logic
//logic
test.startTest();
ClassName.CallFutureMethod(AccountID) ;
test.stopTest();
}
Let me know if you have some more question on this.
Thanks,
Gaurav
Can you provide me the entry rule criteria and the code of your test class that is creating the records matching to the entry criteria?