+ Start a Discussion
Ravi Dutt SharmaRavi Dutt Sharma 

Setting value of an apex defined variable present in flow from aura component


I am trying to launch a flow from an aura component. In the flow, I have an apex variable of type "Apex-Defined Collection variable". How to set the value of this variable from the aura component? I have two other string variables in the flow, I am able to set them, but when I set the value in the apex defined var, the flow throws an error. Below is the relevant code from the aura component:
const flow = component.find("flowData");
const inputVariables = [
            name: "varCaseId",
            type: "String",
            value: component.get("v.recordId")
            name: "varAccountNumber",
            type: "String",
            value: response.accountNumber
            name: "varIntents",
            type: "Intent",
            value: response.intents
flow.startFlow(response.flowAPIName, inputVariables);
If I remove the third element from the inputVariables array, then the flow launches correctly, otherwise not.

ShirishaShirisha (Salesforce Developers) 

Hi Ravi,


Please be informed that "An Apex-defined variable value can't be set or stored outside the flow. The value can't be passed to a Subflow element."This has mentioned in the considerations for the Apex-Defined Data Type publised by the Salesforce.

Reference:https://help.salesforce.com/articleView?id=flow_considerations_apex_data_type.htm&type=5Kindly mark it as best answer if it helps so that it can help others in the future.

Warm Regards,
Shirisha Pathuri


Ravi Dutt SharmaRavi Dutt Sharma
Hi Shirisha,

Thanks for your reply. I had referred to that link earlier. But I am able to pass the value to an apex defined variable from a flow to a sub flow. So I am not sure whether that link has the correct and updated information or not.