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
Pedro Afonso Polo AlbaPedro Afonso Polo Alba 

My table dont shows me any record...

Hello Folks,

I´m trying to retrieve records from my salesforce object, following the controller´s code.

 

public List<INSUMO__c> insumosList ;
    public list<GUIA_SOLIC_COMPL__c> complGuiaList;
    
    
    public GUIA_SOLIC_ITEM__c item_guia ;
    public INSUMO__c insumo;
    public GUIA_SOLIC_COMPL__c guiaCompl{get;set;}
    Public list<INSUMO_APROVADO__c> InsumosAprovados{get;set;}
    
    public TesteGuiasList(){
        //Instancias construtor
        this.insumosList  = new List<INSUMO__c>();
        this.complGuiaList = new List<GUIA_SOLIC_COMPL__c>();
    }
    
    
    public List<INSUMO__c> getInsumosList(){
        
        
        if(!insumosList.isEmpty()){  
            
            insumosList = [select Name,(Select COD_DISTRIBUIDOR__c from Insumos_Aprovados__r ),
                           (select Name,QTD_AUTORIZADA__c,QTD_UTILIZ_PREST__c,QTD_LIBERADA_AUDIT__c,QTD_UTILIZ_INTERM__c from ITENS_GUIA__r  ) 
                           from INSUMO__c Order By Name];
            /* for(Insumo__c Insu : insumoslist){
// insumos_aprovados__r refere-se a todos os records filhos
InsumosAprovados.addAll(insu.insumos_aprovados__r);

}*/
            
            return insumosList;
        }
        return insumosList;
    }


this is a piece of code with just only one method and a constructor. Im doing this select to show on the following VF:

<apex:pageBlockSection title="INSUMOS" columns="1" collapsible="false"  id="pageBlockSectionOpme">
            
            <apex:pageBlockTable value="{!insumosList}" var="insumos" id="tbOpme">
                
                <apex:column value="{!insumos.Name}" headerValue="ID"/>
                <apex:column value="{!insumos.COD_TUSS_DEFINITIVO__c}" headerValue="COD_TUSS_DEFINITIVO"/> 
                <apex:column value="{!insumos.insumos_Aprovados__r[0].COD_DISTRIBUIDOR__c}" headerValue="COD_DISTRIBUIDOR"/>
                
            </apex:pageBlockTable>
            
            
            <apex:pageBlockTable value="{!insumosList}" var="itens" id="tbOpme2">
                <apex:column value="{!itens.Name}" headerValue="ID"/>
                <apex:column value="{!itens.ITENS_GUIA__r[0].QTD_SOLICITADA__c}" headerValue="QTD_SOLICITADA"/>
                <apex:column value="{!itens.ITENS_GUIA__r[0].QTD_AUTORIZADA__c}" headerValue="QTD_AUTORIZADA"/>
                <apex:column value="{!itens.ITENS_GUIA__r[0].QTD_UTILIZ_PREST__c}" headerValue="QTD_UTILIZ_PREST"/>
                <apex:column value="{!itens.ITENS_GUIA__r[0].QTD_LIBERADA_AUDIT__c}" headerValue="QTD_LIBERADA_AUDIT"/>
                <apex:column value="{!itens.ITENS_GUIA__r[0].QTD_UTILIZ_INTERM__c}" headerValue="QTD_UTILIZ_INTERM"/>
                
                
            </apex:pageBlockTable>
      
    

        </apex:pageBlockSection>
        
    </apex:pageBlock>


The error tells me that the position [0] dont have any record, but i tried anothers indexes with all fields... and even so doenst shows me anything.

what i want to know is; how can i retrieve all records from my objects and show on the VF.

Note: i have tested this query in the query editor and shows exactly what i need. is that possible im not getting the datas and inputing to the list?

Thank´s guys!

Cya.

UC InnovationUC Innovation
Hi Pedro,

It looks like in your getInsumosList() function, you check if the list is not empty before calling the query. If that function is the only time you populate your list, then it's likely that the list is always staying empty.

Maybe you should check to see that the list is empty before calling the query? How come it is necessary to check if the list is not empty?