1

I am having a Standard object Contact which has a relationship with an Custom Object Demo__c.

So, in Contact Page Layout, we can create a new Demo__c record by clicking the New button.

I am overriding the New button of Demo__c object.

So, I am wondering how to get Contact ID from URl, when I will click the New Button from the Contact Page layout.

I can see the URL coming ?CF00Nj0000003ZA8g=Mr.+Sanket+Biswal&CF00Nj0000003ZA8g_lkid=003g000000KM0e1&scontrolCaching=1&retURL=%2F003g000000KM0e1&sfdc.override=1

and retURL contains the Contact ID, but how to fetch it in the class?

1 Answer 1

2
string conID = apexpages.currentPage().getParameters().get('retURL');
conID = conID.replace('%2F,'');

Will get you the value of the return URL and replace the %2F

It would be cleaner if you just update the custom button to pass the conID in the URL parameters and then you can just get that parameter.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .