[SalesForce] How to get the current record ID from within a Visualforce Lightning component (without using a Standard Controller)

How do I get the record ID of the current record (regardless of object type) when I am writing Visualforce / Apex that is running inside of a Visualforce Page included in a lightning page layout via a lightning Visualforce Page component?

This question was originally marked as a duplicate – Accessing Record Id inside a lightning app page component (visualforce page used as component) controller

The solution described is to use a Standard Controller plus an extension. In my case since this page could appear on any object layout (i.e. Account, Opportunity, Case etc…) and because as I understand it a Standard Controller requires an object literal I don't think this method is viable to grab the ID and utilize the same VF Page across all potential objects it may be placed on.

Best Answer

Is using the recordId interface within the Lightning Component an option?

Such as:

    <aura:component implements="force:lightningQuickAction,force:hasRecordId,force:hasSObjectName" access="global" >
    <aura:attribute name="recordId" type="String"/>
    <aura:attribute name="sObjectName" type="String" />
    <b>{!v.recordId} </b><br/>
    <b>{!v.sObjectName} </b><br/>
</aura:component>

I am not sure if this solves the visualforce part of your issue though.