+ Start a Discussion
torotoro 

How to get field label?

Hello,

 

Hopefully easy question.

 

I'm trying to create PDF page and trying to format it nicely.

 

I have datatable with columns to list items I want to show.

Since I want to line up all lable and data field nicely, I've put 4 columns (label, data, label, data).

 

The question is how can I get the label of the field?

I've tyied <apex:outuputlabel value="{!Opportunity.Account.Name.label}"/>

also tried <apex:outuputtext value="{!Opportunity.Account.Name.label}"/>

 

 but didn't work.

 

    <apex:dataTable value="{!Opportunity}" var="o" columns="4" columnsWidth="150px, 220px, 150px,220px" >
    <apex:column >
    <apex:outputlabel value="{!o.Account.Name.label}" />
    </apex:column> 
    <apex:column >
    <apex:outputText value="{!o.Account.Name}" />
    </apex:column> 

 

 

Best Answer chosen by Admin (Salesforce Developers) 
bob_buzzardbob_buzzard

The $ObjectType global should give you this:

 

<apex:outputLabel value="{!$ObjectType.Account.fields.Name.Label}" />

 

All Answers

bob_buzzardbob_buzzard

The $ObjectType global should give you this:

 

<apex:outputLabel value="{!$ObjectType.Account.fields.Name.Label}" />

 

This was selected as the best answer
torotoro

Thanks for quick help!

That'sit.

Marc C.Marc C.
Bod, do you know how to get the label for a field in a custom setting?
Karun ManujaKarun Manuja

but how to get the label for a custom field on a Custom object ?

Rahul SherikarRahul Sherikar
Can we display stand fields label also by using {!$ObjectType.ABC__c.Fields.CreatedBy.Label} or not ?