Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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)}" >
</apex:page>

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

share|improve this question
up vote 9 down vote accepted

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:

retUrl=URLFOR($Action.Case.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
share|improve this answer
1  
Thanks Adrian ! – Nick Mar 17 at 20:29
    
@Nick Glad I could help! – Adrian Larson Mar 17 at 20:30

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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