+ Start a Discussion
etessetess 

Display Related List Based on Account "Type" field

I'm new to Visualforce and APEX;

 

Here is some background on what I am trying to do - Each Account is assigned either "Agency" or "Client" picklist values under the "Type" field. (I am using Professional edition, so I am not able to create different Account Record Types). My company's Opportunities always relate to TWO Accounts - one of each type. I currently have the Opportunity Account Name field looking up Agency Accounts and a custom look up field to assign the Client Account.

 

The issue I have is displaying redundant Related Lists on the Account Page - for "Agency" accounts, this is fine.. the Opportunities show up under "Opportunities" related list. For Client Accounts, however, the related Opportunities display on a separate related list created by the custom look up field.

 

Any direction on the best way to tackle this is appreciated - below I've listed my ideas, but I don't know how to execute any of them (I'm shuffling around in the Visualforce inline page documentation but quite confused...) Also - please let me know if what I am trying to do requires Enterprise.

-HIDE empty related list

-DISPLAY related list based on Account Type Field value (using an inline visualforce page?)

-restructure how i point opportunities to multiple accounts..

Best Answer chosen by Admin (Salesforce Developers) 
etessetess

I managed to solve this creating custom VF pages and just using an IF formula in the render field for which related list to display - no enterprise necessary.

All Answers

bob_buzzardbob_buzzard

We encountered something similar a while ago with up to 4 accounts associated with a single opportunity, leading to four related lists.  We created a visualforce page that retrieved all of the opportunities that an account was associated with and displayed them in a single list view clone.

 

I don't think you'll be able to do this using standard controllers though, so Enterprise would be required for the apex classes.

etessetess

I managed to solve this creating custom VF pages and just using an IF formula in the render field for which related list to display - no enterprise necessary.

This was selected as the best answer
mktforcemktforce

I'd love to learn more about how you solved this. Could you post a code sample?

etessetess

Sure -

 

 

<apex:relatedList list="Opportunities" rendered="{!IF(CONTAINS(Account.Type,'Client'), false, true)}"/>

 

 

john s.john s.
Hello Folks,

I'm also new to VF and APEX  

How i can  hide  an Section in an Page layout  if an Fields is Bank ? 

regards john 

 
Prasanth Reddy 51Prasanth Reddy 51
Hello Folks,
I am new to Apex and VF. I have a similar requirement to hide Related lists based on Parent field value. Where exactly i have to put the below code and how to reference this VF page on UI? apprecite your help on this.
<apex:relatedList list="Opportunities" rendered="{!IF(CONTAINS(Account.Type,'Client'), false, true)}"/>

Thanks,
reddy.