+ Start a Discussion
kdmrkdmr 

How to get Id from the Url

Hi,

I am using a visualforce page to override 'New' for an object called Obj1. This object is also part of a related list in another custom object Obj2. I would like to get the Id of the Obj2 record from where New is clicked in the controller class for the visualforce page. I am not sure how to get this done. Please help.

Thanks

KD 

cvjcvj

If Obj1 is a related list on Obj2, you have a master detail relationship.  The Id for Obj2 will be stored in this relationship field, and is accessible from Obj1 directly in your controller.  

 

Obj1.RelationshipFieldName__c 

 

You don't need to look it up from the url.

kdmrkdmr

Yes I understand that. But in my UI i am using an inputtext instead of a inputfield. So i would like to get the Id from the url.

 

Thanks

Krishnadas 

MVJMVJ

 

Basicly what you want to do is:

 

System.currentPageRefrecne().getParameters().get('var')

 

Hope this helps you out.  Check out the Force.com CookBook for more examples.