I have a custom Object called "Related Professionals" and I overrided the 'New' button to auto populate the "Name" Field with the Default text.

This is the New button Override VF page :

<apex:page standardController="RelatedProfessionals__c" action="{!URLFOR($Action.RelatedProfessionals__c.New, null,[Name='Default',retURL='/a16/o'],true)}" >

I don't want the retURL to be hardcoded like that(since Id of custom object wouldn't not be consistent between sandbox's).

What options do I have on Visualforce page to not hard code that ID?

*I don't have a controller for this Object and would like to avoid using one if possible


You can use the $ObjectType global variable to get the key prefix:

retUrl='/' & $ObjectType.RelatedProfessionals__c.keyPrefix + '/o'

You can't use it here, but with some SObjects, you can use the $Action global variable to get the tab:


Unfortunately, the only supported types are:

  • Ad group
  • Campaign
  • Case
  • Contact
  • Contract
  • Google campaign
  • Keyword
  • Lead
  • Opportunity
  • Product
  • Search phrase
  • SFGA version
  • Solution
  • Text ad

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.