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

Currentpage Name?

Does anyone know how to get the currentpage name as in the Visualforce Name in Apex?


PageReference pageRef = ApexPages.currentPage(); doesn't give me the name without writing code to pull it out.


I simple need a way to grab the name so I can set the title and content dynamically through an object.


My only work around would be writing the pageref to the object but when I write to the field I get and error:  Invalid bind expression type of System.PageReference for column of type String.


Please help asap.




Try the code given below :




This will acceess the name of current page.


Did this answer your question? if so, please mark it solved.


I need it in Apex not Visualforce.


In my opinion, you can not get current page name by any apex page method.


Try this out by using string split method :


String strurl = ApexPages.currentPage().getUrl();

String strurl = strurl.split('apex/')[1];


Hope this helps.


This helped me too! Quick and easy.

Thanks, Predeep_Navatar!