You need to sign in to do that
Don't have an account?
Charline Mitchener
Display values from a secondary account linked to contact in visualforce page
I have create a visualforce page, using apex that looks up and displays a number of fields from the contact object as well as the account linked to that contact.
A number of contacts have a 'secondary account', which they are linked to. There is a custom field on the contact layout named secondary_account__c, which is an account lookup field.
I need to display fields from both accounts within the visualforce page, i.e. the Address from both Accounts within the one visualforce page. How would I detail this within the apex code I have created? If I just have , account.billingcity for example, how would I add it, and differentiate it from the first account, to show the billing city for the second account?
A number of contacts have a 'secondary account', which they are linked to. There is a custom field on the contact layout named secondary_account__c, which is an account lookup field.
I need to display fields from both accounts within the visualforce page, i.e. the Address from both Accounts within the one visualforce page. How would I detail this within the apex code I have created? If I just have , account.billingcity for example, how would I add it, and differentiate it from the first account, to show the billing city for the second account?
If you want to display secondary account name then you can do like this.
Thanks.
Added the fields to the apex controller, which I presume are correct as I didn't receive an error message
Secondary_account__r.BillingCity,
Secondary_account__r.billingstreet,
Secondary_account__r.billingstate,
Secondary_account__r.billingpostalcode,
Secondary_account__r.billingcountry,
Secondary_account__r.Trading_Name_ABN_Number__c,
Secondary_account__r.Trading_Name__c,
Secondary_Account__r.Entity_Name__c,
Secondary_account__r.Company_AR_Number__c,
And added the code to the VF page -
(sample)
<apex:outputText value="{!contact.Secondary_account__r.Entity_Name__c}" />
<apex:outputText value="{!contact.Secondary_account__r.Company_AR_Number__c}" />