function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Jessie Rymph 3Jessie Rymph 3 

how is "record id" used in VF page Lightning component?

pop up when adding a visualforce page in lightning I'm dragging the Visualforce Page Component to the Home page layout in Community Builder and I get this pop up box. I can't find any documentation to tell me what to do with this recordId. I would love to pass values to the VF page, but I'm not sure how. 
Best Answer chosen by Jessie Rymph 3
SScholtzSScholtz
For Jessie, and for anyone else who comes by here via web search, the answer is that the Id is passed via query string params, so with the VF page you can use...

{!$CurrentPage.parameters.Id}

...and in apex page controller you can use...

String myId = ApexPages.currentPage().getParameters().get('Id');

All Answers

SScholtzSScholtz
For Jessie, and for anyone else who comes by here via web search, the answer is that the Id is passed via query string params, so with the VF page you can use...

{!$CurrentPage.parameters.Id}

...and in apex page controller you can use...

String myId = ApexPages.currentPage().getParameters().get('Id');
This was selected as the best answer
Jessie Rymph 3Jessie Rymph 3
@Shagz thanks for responding! So is the box for "Record ID" actually adding any fuctionality? You could already query for the record id that way, right? THanks! 
SScholtzSScholtz
Hmmmm, I'm not in a position to test this out at the moment, only posted back here as I was helping a co-worker figure it out today.

I can check tomorrow, but what happens if you leave the record id field empty, null, is the {!$CurrentPage.parameters.Id} still available to be used by your VF page?  If yes, I don't know what the field is doing then. ;P  But if not....there you go, that param is passing the current context's record id to the VF page.

Having said that...

You mentioned this was on your community builder "home page".  In this context, having the record id field value be {!recordId} does nothing (I think), because you're working on a home page, not a record page, so there's no record context to pass to your VF page.  If you were using the app builder to make a record page, then that makes sense, I'm on Case 123 or whatever, and the id of Case 123 is what's passed to the VF page inside the component if you're using {!recordId}. ( think)

If you wanted to do something custom where you wanted to pass along certain kinds of arguments to your VF page to use, you'd have to make a custom component that implements an iframe to your VF page, and exposes settings for the page builder use to set when they use your component, something like this perhaps: https://developer.salesforce.com/forums/?id=9060G000000MPlLQAW
Jessie Rymph 3Jessie Rymph 3
Thank you!