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
Alejandro MirandaAlejandro Miranda 

Invoke a Flow with Apex Class. Constructor not defined

Hi All,

I am having problems when I try to invoke a Flow with Apex. I'm having the next problem:

Constructor not defined: [Flow.Interview.Asociado_correo_secundario_al_EmailMessage].<Constructor>(Id)

This is the part of code:

  public void beforeInsert(SObject so) {
        Case cas = (Case)so;
        if(cas.Origin=='Email'){
            MainCaseAnalyzer mCA = new MainCaseAnalyzer();
            mCA.analyzeDescription(cas);  
            system.debug('CASO BEFORE INSERT: ' + cas); 
        }
        if(cas.Status=='Reasignado'){
            cas.CAS_CHK_CasoReasignado__c=true;
        }
        
        List<EmailMessage> emailMessageList = [SELECT id,parentId FROM EmailMessage WHERE parentId =: cas.id limit 1];
        Flow.Interview.Asociado_correo_secundario_al_EmailMessage flow = new        Flow.Interview.Asociado_correo_secundario_al_EmailMessage(emailMessageList[0].id);
        flow.start(); 
            
    }

Any idea how to do it?

Thanks in advance!
deepak balur 19deepak balur 19
Please refer to the following link: http://andyinthecloud.com/2014/10/26/calling-flow-from-apex/. This will help your refine your flow invocation from APEX. 
Alejandro MirandaAlejandro Miranda
Thank you for your help ;)