1
    <apex:page standardController="account"  extension="letter">
             <apex:panelgroup rendered="{!account.contact.title=='CEO'}">
                <b>- CEO: CEO</b> <br/>                                              
                 <b> Mr/Mrs/Ms.</b><apex:outputField value="{!contact.name}"/><br/>                                                                                           
                 <b> tel.:</b><apex:outputField value="{!contact.MobilePhone}"/>
                  </apex:panelgroup>
<b> •   Your company  main activity: </b> <apex:outputField value="{!Account.Activity__c}"/>+ <apex:outputField value="{!Account.Industry__c}"/>
    </apex:page>

it is not accepting in salesforce rendered="{!account.contact.title=='CEO'}">

how to get the contact details by controller extension

2

There where a few issues with your Visualforce page code, it was quite close though! I've correct them in the sample below, main issue was the your rendered expression was attempting to look for a 'contact' field on the Account object, this does not exist.

I noticed further down in your page you are referencing the 'contact' directly, which i assumed to be a field you expected your extension controller to provide, which my sample reflects below. I'm not sure how you want to find the specific contact, as many contacts can be associated with an Account, so please adapt the SOQL logic in the extension accordingly.

<apex:page standardController="Account" extensions="letter">
    <apex:panelgroup rendered="{!contact.title=='CEO'}">
        <b>- CEO: CEO</b>
        <br />
        <b> Mr/Mrs/Ms.</b>
        <apex:outputField value="{!contact.name}" />
        <br />
        <b> tel.:</b>
        <apex:outputField value="{!contact.MobilePhone}" />
    </apex:panelgroup>
    <b> • Your company main activity: </b>
    <apex:outputField value="{!Account.Activity__c}" />+ <apex:outputField value="{!Account.Industry__c}" />
</apex:page>

Here is the extension controller...

public with sharing class letter {

    public Contact contact {get;set;}

    public letter(ApexPages.StandardController controller)
    {
        // Resolve the desired contact, below simply takes first one
        contact = [select Name, MobilePhone, Title
                    from Contact where AccountId = :controller.getId() 
                    order by Name limit 1]; 
    }
}

Displaying this page against an Account with a Contact having a CEO title shows this...

enter image description here

Take a look at the Visualforce Developers guide on Extension Controllers for more info.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.