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

Customer Portal Visualforce how set id of page when I click a tab

I am creating an alert tab for my customer portal users via a visualforce tab. I am grabbling the contactId via {$User.ContactID} and want to set the current page to this ID when a user click this tab from the Home tab.  Am I going to have to make every tab a VF tab and pass the param that way or is there a way to set the Current Page id to a default id?

I'd like to have it automically set to something like this


<apex:page standardcontroller="Contact" showHeader="true">

<apex:param name="aid" value="{!$User.ContactId}"/>

<h1>Alerts will go here</h1><br/>



Thanks in advance,



Best Answer chosen by Admin (Salesforce Developers) 

And that is why it has to be a web tab. For Step 3, Enter the URL, you can append with dynamic vars ... so your URL would look like:[YourPodNum][YourPageName]?id={!User_Contact_ID}




All Answers


I think you mean a web tab pointing to the VF page.  Which I think in theory would work, but use:



 Instead, and that will flow right into the standard controller.


Alternatively, ditch the standardController and get the information you need via Apex in a custom controller.  In Apex you can use UserInfo.getUserId() to get the current user's ID, and if they're a portal user you can get their contact ID and subsequent information from that.




Yes I mean a web tab pointing to a VF page. Is the id={$User.ContactID} supposed to go into the apex:page tag as such?


<apex:page standardcontroller="Contact" showHeader="true" id="{!$User.ContactID}">


If I do this it says "Literal value is required for attribute id in <apex:page> in Customer_Alerts. " 


I see how to get the id information but how do I actually take that id and set the page to it without having to click on something? I was going to make a controller but I wanted to figure out how to make the web tab automatically set to a particular id when you click it.


StandardController will automagically load the record of the associated SObject type based on the id query param.  So:





<apex:page standardController="Contact">




Will display that Contact's name.


How do I set query param to my specified id? I want to associate the record myself, I don't want the user to click on something to do it other than clicking the tab. Right now the user would click on the tab and see  a list of records. They would click on this record and then it would be associated.

I want the user to be able to click the web tab and in visualforce and have it coded to associate the record of my choosing.


(how do I set this in VF?)





And that is why it has to be a web tab. For Step 3, Enter the URL, you can append with dynamic vars ... so your URL would look like:[YourPodNum][YourPageName]?id={!User_Contact_ID}




This was selected as the best answer

Ahhh. Now I feel silly. Thanks for all your help!!


No problem.  TBH, it's kinda weird we don't have that option on VF tabs as well.


Hi Joshbirk,


Thank you for your post in this. It was very helpful to understand how to point to VF page from web tab. I'm trying to "extend" what Dahveed did by directing the Web Tab URL to a page that uses standard controller detail for custom object and it's associated ID. Can you pls recommend what the simpliest solution would be for this? Any input would be greatly appreciated.


Thank you for all your help in advance.





I'm not sure if this helps or is what you are asking but I wound up creating a custom list controller and  visualforce list page link via web tab.  I put this in the visualforce page list page to link to my custom visualforce view page.

<apex:outputLink value="apex/Portal_Case_View?id={!case.Id}">{!c.CaseNumber}</apex:outputLink>

 This points to my visualforce page and passes the id.  If you wanted to go to, say the standard case, you would just use


<apex:outputLink value="/{!case.Id}">{!c.CaseNumber}</apex:outputLink>

This should work for any custom object as well replacing the "case"  with "myCustomObject__c.Id"


Hope this helps