[SalesForce] Calling Flow from Lightning Quick Action

I'm trying to call a flow from a lightning action on the opportunity object. The flow is called from a button in classic, but buttons do not appear in lightning. A URL hack of that button allows me to pass the record id of the current opportunity record into the flow using the button url. I have created a Flow quick action to run the flow in lightning (Opportunities>Buttons,Links and Actions>New Action> Action Type= Flow) but I keep getting a fault error when trying to run the flow. Essentially, the error fails because there's no way to pass in the record id for the current record with the action.

Best Answer

NOTE: URL hacks do not work in lightning experience.

Flow Type: Flow actions support only flows that include screens.

Input Variables Flow actions let you pass the value of the record's ID field into the flow, but that's it. If your flow has a Text input variable called recordId, the action passes the record's ID into that variable at runtime. If not, it doesn't and the flow tries to run anyway.

So the above is relevant only if your'e using screen flows Add a Flow As an Action on a Record

If you do need to use a flow without screens you can leverage lightning components(Embed a Flow in a Custom Lightning Component) to pass the recordId to the flow

<aura:component>
    <aura:handler name="init" value="{!this}" action="{!c.init}" />
    <lightning:flow aura:id="flowData" />
</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");
    },
})

If you want to end up using in both classic and lighting use a custom button to Embed Flows in Visualforce Pages

<apex:page standardController="Opportunity" tabStyle="Opportunity" >
    <flow:interview name="ModemTroubleShooting">
        <apex:param name="oppId" value="{!Opportunity.Id}"/>
    </flow:interview>
</apex:page>