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
indyinfyindyinfy 

How to get Acoount object values in a VF page whose standard contoller is Contact??

Hi All

I have created a VF page to add a contact without using the standard Contacts tab.

See the code below. I am able to save the contact info with no issues. But what I want is

when I select an Account in this page which is a look up I have to get the Revenue value

for the selected Account before I save the page. Is this possible in Visual Force Page?

If possible how this can be achieved?

 

<apex:page standardController="Contact">

<script language="JavaScript">

function showAccRevenue()

{  alert ("How to get a/c revenue");}

</script>

<apex:pageBlock>Create New Contact Quickly</apex:pageBlock>

<apex:Form>

<table>

<tr><td>First name:</td>

<td><apex:inputField value="{!Contact.FirstName}"/></td></tr>

<tr><td>Last name: </td>

<td><apex:inputField value="{!Contact.LastName}"/> </td></tr>

<tr><td>Phone: </td>

<td> <apex:inputField value="{!Contact.Phone}"/> </td></tr>

<tr><td>Account</td>

<td><apex:inputField id="txtAcc" onblur="showAccRevenue();" value="{!Contact.AccountId}"/></td></tr>

</table>

<apex:commandButton action="{!save}" value="Save"/>

</apex:Form></apex:page>

 

Ron HessRon Hess
it's a bit easier than that

Code:
<apex:page standardController="Contact">

<apex:pageBlock>Create New Contact Quickly</apex:pageBlock><apex:Form><table><tr><td>First name:</td><td>
<apex:inputField value="{!Contact.FirstName}"/></td></tr><tr><td>Last name: </td><td>
<apex:inputField value="{!Contact.LastName}"/> </td></tr><tr><td>Phone: </td><td>
&nbsp;<apex:inputField value="{!Contact.Phone}"/> </td></tr><tr><td>Account</td><td>
<apex:inputField id="txtAcc" value="{!Contact.AccountId}"/></td>
<tr><td>
<apex:outputField value="{!contact.Account.AnnualRevenue}" ></apex:outputField></td></tr>
</tr></table>

<apex:commandButton action="{!save}" value="Save"/></apex:Form></apex:page>

 
you can specify the value using the relationship dot syntax
indyinfyindyinfy

Thanks for the response Ron. But I get a databinding error as shown below.

Could not resolve the entity from &lt;apex:outputField&gt; value binding '{!Contact.Account.AnnualRevenue}'


 

indyinfyindyinfy

Thanks for the response Ron. But I get a databinding error as shown below.

Could not resolve the entity from &lt;apexutputField&gt; value binding '{!Contact.Account.AnnualRevenue}'

Vivek ManchandaVivek Manchanda
Hi try to use this ----------

<apex:page standardController="Account">
<apex:pageBlock title="Hello {!$User.FirstName}!">
You are displaying values from the {!account.name} account and a separate contact
that is specified by a query string parameter.
</apex:pageBlock>
<apex:pageBlock title="Contacts">
<apex:dataTable value="{!account.Contacts}" var="contact" cellPadding="4" border="1">
<apex:column>{!contact.Name}</apex:column>
</apex:dataTable>
</apex:pageBlock>
<apex:detail subject="{!$CurrentPageReference.parameters.cid}" relatedList="false"
title="false"/>
</apex:page>

This to call the Account related contact data in your Application .

May be you can get some help .

Vivek Manchanda
Ron HessRon Hess
perhaps annual revenue is hidden by field level security or profile security?

also, do you have the contact or account id sepcified on the url

.../apex/yourpage?id=001xxxxxxx

Message Edited by Ron Hess on 03-02-2008 11:07 AM