I am trying to pass the recordId and Flow API Name from my LWC to an Apex Class using the imperative method.
I have not issue passing the Flow Name however I recordId is always returning as Null.

I compared my code to that in the post below, but could not find the issue How to pass the record id to controller method from LWC

LWC js

import { LightningElement, api } from 'lwc';
import callFlow from '@salesforce/apex/FlowController.callFlow';

export default class LaunchFlowDemo extends LightningElement{ 
  flowname = 'CaseFollow_Unfollow';
  @api recordId;
  @api async invoke() {
    let result = await callFlow({flow_name: this.flowname},{flow_recordId: this.recordId});

Apex Class

public class FlowController {
   public FlowController(){
      public static void callFlow(Id flow_recordId, String flow_name) {
       system.debug('flow_recordId =' + flow_recordId);
      //string flowName ='CaseFollow_Unfollow';
      //Id recordId='5004V00001AOwDAQA1';
      Map<String, Object> recordMap = new Map<String, Object>();
        recordMap.put('recordId', flow_recordId);
      Flow.Interview myFlow = Flow.Interview.createInterview(flow_Name, recordMap);
  • in what type of page is your lwc used?
    – glls
    Mar 10 at 4:23
  • 1
    pls check that in your invoke method, just before you call the apex, is the recordId filled
    – Damecek
    Mar 10 at 7:06
  • @gills - I am calling this from an Action button on the record page - there is no LWC page. Mar 10 at 14:41

1 Answer 1


I figured out the issue - it was not with the recordId rather they syntax i was using for the Apex Method. I was putting each of the parameters in separate braces. I adjusted the code accordingly...

LWC js

import callFlow from '@salesforce/apex/FlowController.callFlow';
import {LightningElement, api } from 'lwc';
import {ShowToastEvent} from 'lightning/platformShowToastEvent';

export default class LaunchFlowDemo extends LightningElement{ 
    flowname = 'CaseFollow_Unfollow';
    @api recordId
    @api async invoke() {
      callFlow({flow_recordId: this.recordId, flow_name: this.flowname})  
              this.showToast("Success",'Case Unfollowed',"success")             
              //error handling
    showToast(title, message, variant){
        this.dispatchEvent(new ShowToastEvent({
            title, message, variant

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.