function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Rico Tobias TägderRico Tobias Tägder 

Test Class for Trigger which Launch Flow

Hi Community,
I'm new in writing Apex Triggers and especially writing test classes.

So it shouldnt be a problem as there is a lot to find how to do it, but I dont find something about writing test classes for Triggers which call a Flow. I tried some standard approaches with no luck.

My Code:

trigger CallHwCalculationFlow on Lead_Product__c (after delete) {

//Get Lead__c ID
    Id leadId;
for(Lead_Product__c a: Trigger.old){
    leadId = a.Lead__c;
} 
   
// Call the Flow
Map<String, Object> params = new Map<String, Object>();
params.put('CurrentLeadID', leadId);
Flow.Interview.Update_Total_HW_Price calcFlow = new Flow.Interview.Update_Total_HW_Price(params);
calcFlow.start();
 


}

The part after "//Call the Flow" is hard for me to get. Maybe you have some examples, links or advices.

Thank you very much in advance!
 

 
ShirishaShirisha (Salesforce Developers) 
Hi Rico,

Greetings!

Please check the below link for the sample example on how to write the test class which calls the flow:

https://salesforce.stackexchange.com/questions/73882/unit-test-for-controller-that-calls-a-flow

Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future.

Warm Regards,
Shirisha Pathuri