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
MeWorkingmanMeWorkingman 

How do you access query parameters from VisualForce page in tab?

I have created a VisualForce page that I want to access via a VisualForce tab named myVFTab. I want to pass a query parameter to the VF page like this:

https://salesforce_server/one/one.app#/n/myVFTab?usePrintId=mytest
As you can see, I'm accessing the tab in lightning but I don't think that is relevant to my question.

I am trying to access the "usePrintId" parameter in my VF page like this:
<apex:page>
  These parameters were passed in:<br/>
  <br/>
  PrintId: {!$CurrentPage.parameters.usePrintId}
</apex:page>
If I access the VF page directly, the "usePrintId" parameters prints out correctly but if I try to view the tab, the "usePrintId" is always blank.

How do I make sure that the parameter in the tab request is available in the contained VF page?
 
Alain CabonAlain Cabon
Hi,

Passing parameters in the URL is not possible with a custom tab associated with a VFP.

From Apex or a URL button, you can call the VFP directly with parameters as you noticed.

You can use tabs (sub tabs) inside an existing VFP (same main tab) on the other hand. I used these tabs for my own technical tool.

https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_compref_tabPanel.htm

This custom VFP tab are used for independant pages in the application with a prepopulated dropdown menu for example and a custom controller as described here: We have used them like that

https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_controller_custom.htm
 
Naval Sharma4Naval Sharma4
Can you not try with using javascript code. Just get the URL using window.location.href and then parse the URL to get the parameter.
MeWorkingmanMeWorkingman
@Naval Sharma4: Unfortunately, I can't use javascript to pull the parameter. I've tried to do it and I get a security exception whenever I try to access the window object. Besides, I'm pretty sure that the parameters aren't even being passed from the tab to the VFP so the parameter won't be available in the query string of the URL.

@Alain Cabon: That was what I figured; it just isn't possible to do when invoking a custom tab. I was just hoping that maybe I was missing something. Unfortunately, I can't use tabs within the currently-displayed VFP page because I'm trying to implement a view link that is displayed on a list view so my code isn't a part of an existing VFP. I'm trying to implement this in Lightning, so is it possible to create a URL that invokes a Lightning tab that displays a Lightning page app in the tab and then access the parameter in the Lightning app? I'm still pretty new to Lightning so I'm not sure what all can be done when invoking Lightning tabs.

Thanks again.