I'm trying to retrieve the record Id and pass to my the Flow I have included in Lightning Experience but I'm getting some issues. I have already posted the question in Salesforce forums, but with no luck. Any idea here?
[SalesForce] Retrieve record Id – Visual flow (beta) in Lightning Experience
Related Solutions
The Spring '20 release brought the URL hack for prepopulating field values to Lightning. You can now achieve this with custom buttons and links (not Javascript buttons) much like we used to in Classic.
Spring '20 release note: Navigate to a Record's Create Page with Default Field Values
Where: This change applies to Lightning Experience in all editions. This change doesn’t apply to Lightning Out, Lightning communities, or the Salesforce mobile app.
How: To construct a custom button or link that launches a new record with prepopulated field values, use this sample formula:
/lightning/o/Account/new?defaultFieldValues=
Name={!URLENCODE(Account.Name)},
OwnerId={!Account.OwnerId},
AccountNumber={!Account.AccountNumber},
NumberOfEmployees=35000,
CustomCheckbox__c={!IF(Account.SomeCheckbox__c, true, false)}
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>
Best Answer
Create a new variable in your flow, with entry permission, not private, and call this {!recordId}
Before you try it, must to remove component flow from your page layout > save > put again flow component in page layout and try it
If you create the recordId variable after put the flow component in the page layout, doesn't work, maybe something wrong with Browser Cache.
http://raspisdojo.com/academy/flows-with-recordid-in-lightning-experience-winter17/
If you have any issue, comment this.
Good luck!!