0

I am trying to assign an input variable from the URL.

What i have so far is this

<aura:component implements="lightning:isUrlAddressable,force:appHostable,flexipage:availableForAllPageTypes,force:lightningQuickAction" access="global" >
    <aura:handler name="init" value="{!this}" action="{!c.doInit}" description="Handler for valueInit event fired when the component has been initialised"/>
    <lightning:flow aura:id="Easy_WO_Flow " />
</aura:component>

CONTROLLER

({
    init : function (component) {
        // Find the component whose aura:id is "flowData"
        var flow = component.find("flowData");
        // In that component, start your flow. Reference the flow's Unique Name.
        flow.startFlow("myFlow");
    },
    {
        name : "varName",
        type : "flowDataType",
        value : valueToSet
    },
})

1 Answer 1

0

When you embed a flow in a custom Lightning component you need to pass variables in an array. You missed [] in your code

    ({
    init : function (component) {
  // Find the component whose aura:id is "flowData"
 var flow = component.find("flowData");
// In that component, start your flow. Reference the flow's Unique Name.
 flow.startFlow("myFlow");
 },
[{
     name : "varName",
     type : "flowDataType",
     value : valueToSet
}]
 })

Things to consider:

  1. You can set variables only at the beginning of an interview, and the variables you set must allow input access. For each flow variable.
  2. input access is controlled by The Input/Output Type variable field in the Cloud Flow Designer.
  3. If you reference a variable that doesn’t allow input access, attempts to set the variable are ignored.
  4. sObject values can be assigned in following way

    {name : "VARIABLENAME", type : "SObject",
     value: {
             "Id" : RECORDID,
             "FIELDAPINAME" : "VALUE"
             }
          },
     },
    

    If you have sobject as variable in your component then you can directly assign that sobject as show below

        <aura:component controller="AccountController" >
             <aura:attribute name="account" type="Account" />
             <aura:handler name="init" value="{!this}" action="{!c.init}"/>
             <lightning:flow aura:id="flowData"/>
        </aura:component>
    

    Controller:

        var inputVariables = [
           {
              name : "account",
              type : "SObject",
              value: component.get("v.account")
           }
        ];
    
        flow.startFlow("myFlow", inputVariables);
    

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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