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
Nikvm257Nikvm257 

get object id programatically

Hello Gurus

 

Please let me know if it is possible to get the object Id of say Account object using some prome / code line in vforce

 

What i m talking about 

if below is the link

https://cs4.salesforce.com/001300000099rPu

 

for Account XYZ then how can I get 001300000099rPu this Id in vforce

 

like

fu( Account1 ) = ID

 

Thanks in advance!

 

 

 

 

 

 

 

Best Answer chosen by Admin (Salesforce Developers) 
Starz26Starz26

To get the ID of the current record in a VF page, you can do two things:

 

1. Get page parameter

 

ID accID;

 

accID = ApexPages.CurrentPage().getparameters().get('id');

 

2. Get current record

 

Account acct;

 

acct = (Account)controller.getRecord();

 

then use acct.ID

 

All Answers

Sam27Sam27

In visualforce page you can get the URL as {!$CurrentPage.URL} (not sure abt exact syntax still)

 

I think one way is to get it in a javascript function split it with '/' and get the last part which is the id value

 

 

or on a second thought if you can get sure that id is 15 character value you can use {!RIGHT($CurrentPage.URL,15)}

 

that might work but not exactly tested.

 

hope that helps.....let us know the result.

 

Starz26Starz26

To get the ID of the current record in a VF page, you can do two things:

 

1. Get page parameter

 

ID accID;

 

accID = ApexPages.CurrentPage().getparameters().get('id');

 

2. Get current record

 

Account acct;

 

acct = (Account)controller.getRecord();

 

then use acct.ID

 

This was selected as the best answer
Nikvm257Nikvm257

Thanks @starz, @sam 

 

Thank you very much fore reviewing the post.

Your responses were very helpful.

I will work over them and try to post the reult here

 

Thanks again !