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
pluviosillapluviosilla 

Infinite Loop - How do I hardcode a VF page to navigate to a specific record?

I want a VF web tab to navigate to a specific record, and so I defined the VF page ("TestNameExperiment") like this:

 

<apex:page standardController="My_Custom_Object__c"

                              action="{!URLFOR('/apex/TestNameExperiment?id=a0bE0000000PCIC')}" >

 

where a0bE0000000PCIC is the record ID.

 

This caused an infinite loop in which the VF page loads over and over again, which makes sense in hindsight.

 

What's the proper way to do this?

 

 

Best Answer chosen by Admin (Salesforce Developers) 
SteveBowerSteveBower

Ok, I understand... you've got two problems:

 

1. You've coded the Action on your <apex:page> directive to loop to itself.   That's easy to fix, but, you don't really want a VF page anyway.  Just delete the VF page entirely, you don't need it.

 

2. You created a new Web Tab, and, cleverly, thought that a VF page would be the way to go.   However, since you wanted to hard code the ID, and you can't do that with the VF Tab type you went down the path you did.   The trick is to define your tab as a Web Tab instead of as a Visual Force tab.

 

Then instead of giving a fully formed absolute URL (with http://, etc.)  you instead supply a relative URL for the web tab.

 

For example:

 

You would define your Web Tab named: Test Name Experiment to be:

 

/apex/TestNameExperiment2?id=a0bE0000000PCIC

 

Hope this helps, Best, Steve.

All Answers

SteveBowerSteveBower

URLFOR('/a0bE0000000PCIC')

 

/{ID}/o  is the overview page for a record (which is the default so it can be omitted as above)

/{ID}/e  is the url for the Edit page for this record.

 

If you have a VF page defined, for example, for the Edit function, then /{Id}/e will go to that VF page.  If you wish to instead go to the normal page you can do:

/{ID}/e?nooverride=1   same applies for the View function.

 

 

Note: It seems odd to have a dedicated tab to just go to one record.  I'm sure you have a valid case for that, it's just not all that common.

 

Best, Steve.

pluviosillapluviosilla

Thanks for your suggestion. Yes, it is an odd thing to do, and offhand I can't imagine why anyone would do this in a production environment.

 

But this is just a PEDAGOGICAL TOOL. 

 

I want to click a VF tab and:

(1) land on my custom VF page

(2) in the context of a particular record I specify

 

I don't want to have to type in this lengthy URL every time:

https://c.na9.visual.force.com/apex/TestNameExperiment2?id=a0bE0000000PCIC

 

VF tabs get me halfway there, but do not allow me to specify URL parameters, so I am missing the record context I want.

 

Your suggestion fixes the looping problem, for sure, and leaves me in the proper record context, but it takes me away from the custom VF page I want to work on.

 

Thanks again for the really quick & informative reply. I did learn three cool things from your post!!  :smileyhappy:

 

SteveBowerSteveBower

Ok, I understand... you've got two problems:

 

1. You've coded the Action on your <apex:page> directive to loop to itself.   That's easy to fix, but, you don't really want a VF page anyway.  Just delete the VF page entirely, you don't need it.

 

2. You created a new Web Tab, and, cleverly, thought that a VF page would be the way to go.   However, since you wanted to hard code the ID, and you can't do that with the VF Tab type you went down the path you did.   The trick is to define your tab as a Web Tab instead of as a Visual Force tab.

 

Then instead of giving a fully formed absolute URL (with http://, etc.)  you instead supply a relative URL for the web tab.

 

For example:

 

You would define your Web Tab named: Test Name Experiment to be:

 

/apex/TestNameExperiment2?id=a0bE0000000PCIC

 

Hope this helps, Best, Steve.

This was selected as the best answer
pluviosillapluviosilla

YES!!! 

 

That's it. Didn't occur to me to use Web Tab for an internal page!!! Seems obvious now (Duh).

 

Thanks for taking time, Steve.