0

I am not a developer, but I can do some things with Apex. I have a need to show Visualforce page with the set of fields from custom object "Account Overview" on standard "Account" object. My understanding that I can't do it using standard controller and this is my challenge as I don't know where to go from here. I searched on the internet and found tons of information on how to create controller, but nothing works, due to lack of knowledge on how to code.

Here is example of my Visualforce page:

<apex:page standardController="Account_Overview__c"> <br/>
  <apex:pageBlock title="Account Overview"><br/>
        <apex:pageBlockSection ><br/>
        <apex:outputField value="{! Account_Overview__c.Account__c}"/><br/>
            <apex:outputField value="{! Account_Overview__c.Number_Of_Cases__c}"/<br/>
            <apex:outputField value="{! Account_Overview__c.Number_Of_Service_Appointments__c}"/><br/>
            <apex:outputField value="{! Account_Overview__c.Number_Of_Work_Orders__c}"/>         
        </apex:pageBlockSection><br/>
    </apex:pageBlock><br/>
 <apex:pageBlock title="System Information"><br/>
        <apex:pageBlockSection > <br/>
        <apex:outputField value="{! Account_Overview__c.Last_Updated__c}"/> <br/>
         </apex:pageBlockSection><br/>
    </apex:pageBlock> <br/>
</apex:page><br/>

That would be awesome X-Mas gift if anyone can help with this.

1
  • is account_overview__c a child of Account or a parent of Account?
    – cropredy
    Commented Nov 8, 2021 at 2:52

1 Answer 1

0

If the 'Account Overview' custom object is related to the Account via a lookup relationship field, you can use the standard account controller and dot notation to access that information.

For example, if the standard account has a lookup field to the custom Account Overview object named 'Overview__c', you can access data from that record in the visualforce page by calling it like 'Account.Overview__r.Number_of_Cases__c'.

If the custom object looks up to the Account(ie on your custom object you have a lookup relationship field that points to the Account named 'Account__c', you can access it via its relationship name (ie Account.Account_Overviews__r[0].Number_of_Cases__c'). The reason for the '[0]' in this string is that we are calling fields from a related list of objects to the account. By adding the [0] to the query string, we are telling Salesforce we want the data from the first record (position 0) in the list.

Using this approach will remove the need for a custom controller.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .