You need to sign in to do that
Don't have an account?
src0010
Question about 'apex:outputText' & 'apex:outputField' value format
The following line:
Account: <apex:outputText value="{!X360_Contract_Cycle__c.Account__c}" />
Produces the following on my VisualForce page (rendered as pdf):
Prepared for: 001Q0000008olvcIAA
I tried changing this to outputField instead of outputText (example below):
Account: <apex:outputField value="{!X360_Contract_Cycle__c.Account__c}" />
This displays the account name correctly (not the record ID). That is good....except it included the account name as a selectable link on the rendered PDF. What is the best way to output the value, not as the record ID, and not include the value as a link? So far running into a little bit of a catch 22. Thanks in advance for the help!
Hi,
This is easy to display the account name but not a link using the outputText component.
try this:
You have to select the Account__r.Name from the object before using it.
Cheers
All Answers
Outputfield:
A read-only display of a label and value for a field on a Salesforce object. An outputField component respects the attributes of the associated field, including how it should be displayed to the user. For example, if the specified outputField component is a currency field, the appropriate currency symbol is displayed. Likewise, if the outputField component is a lookup field or URL, the value of the field is displayed as a link.
outputtext :
Displays text on a Visualforce page.
outputtext is a good option...you need to retrieve the name in the query if you are using it...
Hi,
This is easy to display the account name but not a link using the outputText component.
try this:
You have to select the Account__r.Name from the object before using it.
Cheers
Like Eriksson mention the best way is to retriebve the name from the relation:
Account: <apex:outputText value="{!X360_Contract_Cycle__c.Account__r.Name}" />
If this dosn't work for you then you have to get the value on a String throw the controller associated to the page and then display that string, but this is not the correct way to do it.
Does some of this help to you?
Let me know.
Regards,
Olivedr
That did it! I used the dot notation in SOQL previously, but did not think about that being available for outputText to establish the relationship. Thanks for everyones help!
apex:outputField: A read-only display of a label and value for a field on a Salesforce object.
<apex:page controller="SampleTest" tabStyle="Account">
<apex:form >
<apex:pageMessages />
<apex:pageBlock id="pgb">
<apex:pageBlockSection columns="1">
<apex:outputText >Sample Output Text</apex:outputText>
<apex:outputField value="{!acct.Name}"/>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
Apex Class:
public class SampleTest {
public Account acct {get;set;}
public Sample() {
acct = [SELECT Name, Industry FROM Account LIMIT 1];
}
}