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
uptime_andrewuptime_andrew 

Set tabStyle dynamically

Hello,

 

I am creating a visualforce page, and want to set the tabStyle attribute based on Record Type.  However, when open the visualforce page with the following (where MyTabStyle is a string like 'contact', 'account', etc).

 

 

 

 

<apex:page standardController="Opportunity" extensions="myOppExtension" tabStyle="{!MyTabStyle}">

 

 

I get an error "Error: Invalid tabStyle '{!MyTabStyle}' specified. If you are trying to reference a custom Visualforce tab, you must append '__tab'".

 

Is setting the tabStyle this way supported?

 

Thank you

 

lvivaninlvivanin
To use the styling associated with a custom Visualforce tab, set the attribute to the name (not label) of the tab followed by a double-underscore and the word tab. For example, to use the styling of a Visualforce tab with the name Source and a label Sources, use:
<apex:page standardController="Account" tabStyle="Source__tab">
</apex:page>

Alternatively, you can override standard controller page styles with your own custom stylesheets and inline styles.

 

link

uptime_andrewuptime_andrew

Thanks for the post Ivivanin - however, this isn't quite what I'm looking for.

 

The tabStyle is meant to be dynamic, so could be account, opportunity, contact, etc.  I'm not looking to use a static value for a custom tab.

 

 

 

ISVforce PartnerISVforce Partner

Andrew,

 

Any luck with this? 

vanessenvanessen
seems like there is no direct solution for this ?
Sab L 10Sab L 10
This can be done using If condition and controlling controller method. Pls refer 

http://salesforce.stackexchange.com/questions/7488/conditional-tabstyle
 
In apex page

tabStyle="{!IF(strTabName<>null,strTabName,'Account')}"

In controller

public string strTabName{set;}

public String getStrTabName(){ return null; } 

Or

public String getStrTabName(){ return 'CustomCustomer__c'; }

Thanks to Jaison Hardy. Hope this helps.