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
Rafael.Martins.SantosRafael.Martins.Santos 

Populate multiple columns with values from a field of type list.

Hi,
I'm trying to populate a table with some especifics values.
So I will explain what I want to do.
User-added image
  • In the first column I have the a list of accounts
  • in the second column ("Suporte") I must display only the Status of a Product that have a relationship with Account.
  • In the Third column ("Adm") I must display only the Status of a Product that have a relationship with Account.
  • In the fourth column ("BS/BH") I must display only the Status of a Product that have a relationship with Account.
  • In the fourth column ("ServiceNow") I must display only the Status of a Product that have a relationship with Account.
In my actual code I can only display one register if I filter by especifi Product(For example : Suporte) .

Object Account
Object Produto_da_Mancha__c
  • Each Account have a number of products
  • Each product have a Status.
So, I must display Something Like this:
  • Account Name - Status (Product Suporte) - Status (Product Adm) - Status (Product BS/BH) - Status (Product ServiceNow)

Below I share my visualforce code and APEX Code.

Apex Code:

public class Account_Mancha {
    
      public Account_Mancha(){
          
      }
    
    public List<Account> getTodasContas(){
        
        List<Account> accounts = [SELECT Account.Id, Account.Name, (SELECT Produto_da_Mancha__c.Name, Produto_da_Mancha__c.Conta_Id__c, Produto_da_Mancha__c.Status__c FROM Produtos_da_Mancha__r WHERE Produto_da_Mancha__c.Conta_Id__c != null AND Produto_da_Mancha__c.Name = 'Suporte') FROM Account];
        
       return accounts; 
    }
}

Visualforce Code:
<apex:page showHeader="false" sidebar="false" standardStylesheets="false"
applyHtmlTag="false" applyBodyTag="false" docType="html-5.0" controller="Account_Mancha">
<html>
<head>
    <title>Mancha</title>
    <style>
        CSS Style HERE...

    </style>
</head>
<body>
    <header>
        <div class="bar_container">
            <ul>
            <li>
                <a href="">Oportunidade</a>
            </li>
            <li>
                <a href="">Contas</a>
            </li>
            <li>
                <a href="">Contatos</a>
            </li>
        </ul>
        </div>
    </header>
    <div class="painel">
        <h1>MANCHA</h1>
        <table>
            <tr>
                <th colspan="1" class="celula_em_branco"></th>
                <th colspan="4" class="celula_azul_escuro">MANAGED SERVICES</th>
            </tr>
            <tr>
                <td class="cor_cinza">Conta</td>
                <td class="cor_cinza">Suporte</td>
                <td class="cor_cinza">Adm</td>
                <td class="cor_cinza">BS/BH</td>
                <td class="cor_cinza">ServiceNow</td>
            </tr>
           <apex:repeat value="{!TodasContas}" var="conta">
           <tr>
            <td class="celula_azul_escuro">{!conta.Name}</td>
            <apex:repeat value="{!conta.Produtos_da_Mancha__r}" var="produtos">
            <td class="cor_azul">{!produtos.Status__c}</td>
            <td class="cor_verde">HERE MUST BE ADM STATUS</td>
            <td class="cor_amarelo">HERE MUST BS/BH STATUS</td>
            <td class="cor_azul">HERE MUST BE SERVICENOW STATUS</td>
            </apex:repeat>
            </tr>
          </apex:repeat>
        </table>
    </div>
    <footer>
        <div class="bar_container">
            <ul>
                <li>Company Name</li>
            </ul>
        </div>
    </footer>
</body>
</html>
</apex:page>

I really need a help on this.

Thanks

Rafael