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
mikefitzmikefitz 

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.

 

Gracias

Pradeep_NavatarPradeep_Navatar

Try the code given below :

 

{!$CurrentPage.Name}     

 

This will acceess the name of current page.

 

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

mikefitzmikefitz

I need it in Apex not Visualforce.

Pradeep_NavatarPradeep_Navatar

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.

gazazellogazazello

This helped me too! Quick and easy.

Thanks, Predeep_Navatar!