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

How to get the current visualforce page id?

Hello, this is my doubt, how to get the current visualforce page id? I try with {!$Currentpage.Id} or $Page.Id but dont exists this variables.




I am not sure if you can get ID for the visualforce page. Try Name instead.


What are you trying to do that you need the id for?  Perhaps there is another way....

Ryan DRyan D

I just had to do this today.


vfPageId = [SELECT Id, Name FROM ApexPage WHERE Name = 'YOUR_VF_PAGE_NAME'].Id;

 This will give you the ID of your VF page!  

This came in very handy when I had to find a way of targeting the iframe that my inline vf page was in.

monalisa das 46monalisa das 46
Is there is any other way around? Actually I want to set height for my inline vf's iframe, that is just a page with lightning component stuffed in it. To get the Id of page I have to create the controller just for this purpose.Is there is any other way around