• Pedro Afonso Polo Alba
  • NEWBIE
  • 10 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 1
    Replies

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.


Hi, guys.
i´d like to retrieve a information from a list that i made a sub querie.

Following controller with the visualforce page
 
public TesteGuiasList(){
        //Instancias construtor
        this.insumosList = new List<INSUMO__c>();
        this.complGuiaList = new List<GUIA_SOLIC_COMPL__c>();
    }
    
    public List<INSUMO__c> getInsumosList(){
      
        insumosList = [select Name,COD_TUSS_DEFINITIVO__c,(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 ];
       
        return insumosList;
    }


now following the VF page
 
<apex:pageBlockSection title="INSUMOS" columns="1" collapsible="false"  id="pageBlockSectionOpme">
            <apex:pageBlockTable value="{!insumosList}" var="insumos" id="tbOpme">
                
                <apex:column value="{!insumos.Name}" />
                <apex:column value="{!insumos.COD_TUSS_DEFINITIVO__c}" /> 
                <apex:column value="{!insumos.COD_DISTRIBUIDOR__c}" />  
                
                
            </apex:pageBlockTable>
            
        </apex:pageBlockSection>


I want to show insumos.COD_DISTRIBUIDOR__c in the same colunm, and shows me the following error:   Invalid field COD_DISTRIBUIDOR__c for SObject INSUMO__c


I know what that means, but how to show a field i query on my controller and is not working in my VF.  
 
PS; If my question get confused or you need more information, please let me know!
 
Thnak´s folks!

Hi, guys.
i´d like to retrieve a information from a list that i made a sub querie.

Following controller with the visualforce page
 
public TesteGuiasList(){
        //Instancias construtor
        this.insumosList = new List<INSUMO__c>();
        this.complGuiaList = new List<GUIA_SOLIC_COMPL__c>();
    }
    
    public List<INSUMO__c> getInsumosList(){
      
        insumosList = [select Name,COD_TUSS_DEFINITIVO__c,(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 ];
       
        return insumosList;
    }


now following the VF page
 
<apex:pageBlockSection title="INSUMOS" columns="1" collapsible="false"  id="pageBlockSectionOpme">
            <apex:pageBlockTable value="{!insumosList}" var="insumos" id="tbOpme">
                
                <apex:column value="{!insumos.Name}" />
                <apex:column value="{!insumos.COD_TUSS_DEFINITIVO__c}" /> 
                <apex:column value="{!insumos.COD_DISTRIBUIDOR__c}" />  
                
                
            </apex:pageBlockTable>
            
        </apex:pageBlockSection>


I want to show insumos.COD_DISTRIBUIDOR__c in the same colunm, and shows me the following error:   Invalid field COD_DISTRIBUIDOR__c for SObject INSUMO__c


I know what that means, but how to show a field i query on my controller and is not working in my VF.  
 
PS; If my question get confused or you need more information, please let me know!
 
Thnak´s folks!