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
LaurenP6777LaurenP6777 

Visualforce Tabbed Panel - display field value in Tab Label

I recently recreated my opportunity page layout using a visualforce tabbed panel. I would like to be able to display the number of related quotes on the quotes tab but I can't see to get it to work correctly. It seems like I have all the pieces so I'm not sure what I'm doing wrong. I am using the standard oppty controller with the following controller extension.

 

public class IntOppCon {
private Integer RelatedQuotes;
private Opportunity Opp;
public IntOppCon(ApexPages.StandardController controller) {
this.Opp= (Opportunity)controller.getRecord();
}

public Integer GetRelatedQuotes()
{

RelatedQuotes = [Select count() FROM Quote where Opportunityid = :opp.id];

return RelatedQuotes;

}
}

 

My visualforce page snippet works when I type is like this:

 

 <apex:tab label="{!if(RelatedQuotes>0,"Quotes","Quotes (0)")}" name="Quotes" id="tabquote"

 

BUT the system starts to error out when I do it the way I would like which is like this:

 

 <apex:tab label="{!if(RelatedQuotes>0,"Quotes (RelatedQuotes)","Quotes (0)")}" name="Quotes" id="tabquote"

OR

 <apex:tab label="{!if(RelatedQuotes>0,"Quotes ({!RelatedQuotes})","Quotes (0)")}" name="Quotes" id="tabquote"

 

Can anyone help?

Best Answer chosen by Admin (Salesforce Developers) 
AdrianCCAdrianCC

Hi Lauren!

 

Your problem is in that conditional if, when true you are displaying a string, whatever is between the "". The RElatedQuotes is not replaced with the value from the controller because it's considered part of the string.

Try this code:

<apex:tab label="{!if(RelatedQuotes>0,"Quotes (" + TEXT(RelatedQuotes)	 + ")","Quotes (0)")}" name="Quotes" id="tabquote" />

 

Have a nice day! :)

 

Adrian

All Answers

AdrianCCAdrianCC

Hi Lauren!

 

Your problem is in that conditional if, when true you are displaying a string, whatever is between the "". The RElatedQuotes is not replaced with the value from the controller because it's considered part of the string.

Try this code:

<apex:tab label="{!if(RelatedQuotes>0,"Quotes (" + TEXT(RelatedQuotes)	 + ")","Quotes (0)")}" name="Quotes" id="tabquote" />

 

Have a nice day! :)

 

Adrian

This was selected as the best answer
LaurenP6777LaurenP6777

This worked perfectly! Thank you so much!