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
Marcelo AgostinhoMarcelo Agostinho 

Getting Value from Lookup

 

Hello!
Im here to know my code don't  get value from my VF Page.
My VF Page.
<apex:page controller="CarteiraCliente" action="{!teste}" sidebar="false" contentType="{!contentType}">
    
    <apex:pageBlock rendered="{!showFilter}" >
        <apex:form >
            <p>
                Vendedor &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                <apex:inputField id="vendedor" value="{!filtro.Vendedor__c}" required="false" />
            </p>
            <p> Supervisor &nbsp;&nbsp;&nbsp;&nbsp;
                <apex:inputField id="supervisor" value="{!filtro.Vendedor__r.Supervisao_Vendedor__c}" required="false"/>
            </p>
            
            <apex:commandButton value="Filtrar" action="{!teste}" reRender="carteiraCliente" />
        </apex:form>
        
    </apex:pageBlock>
    
    <apex:pageBlock id="carteiraCliente" title="{!title}">
        <apex:pageBlockTable value="{!valoresClienteMes}" var="cliente" title="Carteira de Cliente">
            <apex:column headerValue="Vendedor" id="nomeVendedor" value="{!cliente.nomeVendedor}" />
            
            <apex:column headerValue="Nome" id="nomeCliente" value="{!cliente.nomeCliente}" />
              
            <apex:column headerValue="valorTreze" id="valorTreze"  value="{!cliente.valorTreze}" />
             
        </apex:pageBlockTable>
    </apex:pageBlock>

</apex:page>

 

My Controller

 

 

public class CarteiraCliente {
    
    public MovimentoMes__c filtro { get; set; }

    public CarteiraCliente() {
        filtro = new MovimentoMes__c();
        showFilter = false;
    }
    
    public aMethod(){
        ..............
        String paramVendedor = filtro.Vendedor__c;
        System.Debug ('=====' +paramVendedor+ '====='); 
        
        String paramSupervisor = filtro.Vendedor__r.Supervisao_Vendedor__c;
        System.Debug ('=====' +paramSupervisor+ '=====');
        .............
    }

 

 On my VF Page, when i get a value from lookup icon and click to go... i get the value on my Apex Class...

     but on my second field i alwas get null.... 

 What's happening? And what i can do to solve it?

Tks again for everything

 

 

Pradeep_NavatarPradeep_Navatar

Can you tell me that in Vendedor__r.Supervisao_Vendedor__c , Supervisao_Vendedor__c field is lookup field or normal field?

 

Tryout the standardcontroller="MovimentoMes__c" and use extension="CarteiraCliente" and let me know if you still have any issue.

Marcelo AgostinhoMarcelo Agostinho

Very tks for your reply!

 

But i solved it with another way...

 

I just initialized my Vendedor_r inside my Constructor

Here is my constructor:

 

 

 

 public CarteiraCliente() {
        filtro = new MovimentoMes__c();
        filtro.Vendedor__r = new Vendedor__c();
        showFilter = false;
 }

 

 So now i have a reference to Vendedor_r inside my filtro attribute.

 

Tks!