You need to sign in to do that
Don't have an account?
SolidLucas
query is not returning value visualforce
Well i'm developing a visualforce page where have a query that returns the value of the fields of my account object, but is not returning nothing on my search. someone could help me?
visualforce page
<apex:page standardController="account" extensions="AccountSearch_clt"> <apex:sectionHeader title="Pesquisa de Cliente" /> <apex:form id="theform"> <apex:pagemessages escape="false" id="messages" /> <apex:pageBlock title="Pesquisa de Cliente ERP" > <apex:pageBlockSection columns="2" > <apex:pageBlockSection columns="1" > <apex:inputText value="{!PesquisaCodCliente}" label="Codigo Cliente/Endereco"> <apex:inputText value="{!PesquisaCodEndereco}" /> - </apex:inputText> <apex:inputText value="{!cia}" label="Cia/Documento"> <apex:inputText value="{!tipoDocumento}" html-autocomplete="off" /> - </apex:inputText> <apex:inputText value="{!NumeroDocumento}" label="Numero Documento/ Razao Social"> <apex:inputText value="{!RazaoSocial}" html-autocomplete="off" /> - </apex:inputText> <apex:inputText value="{!NomeFantasia}" label="Nome Fantasia/ CEP"> <apex:inputText value="{!RazaoSocial}" html-autocomplete="off" /> - </apex:inputText> </apex:pageBlockSection> </apex:pageBlockSection> <apex:pageBlockButtons location="top"> <apex:commandButton value="Pesquisar" action="{!doSearch}" rerender="theform" /> <apex:commandButton value="Cancelar" action="{!cancel}" style="color:red;" /> </apex:pageBlockButtons> </apex:pageBlock> <c:PageBlockTableEnhancerADV targetPbTableIds="pbt" pageSizeOptions="5,10,15,30" defaultPageSize="5" enableExport="false" /> <apex:pageBlock mode="maindetail" id="pb"> <apex:pageblockTable value="{!listAccPesquisa}" var="item" id="pbt"> <apex:column value="{!item.CustomerNumber__c}" /> <apex:column value="{!item['Name']}"/> <apex:column value="{!item.Id}" /> <apex:column value="{!item .Tipo_de_Documento__c}" /> </apex:pageblockTable> </apex:pageBlock> </apex:form> </apex:page>
public with sharing class AccountSearch_clt { public string NomeFantasia {get;set;} public string Pesquisastring {get;set;} public string PesquisaCodCliente {get;set;} public string PesquisaCodEndereco {get;set;} public string cia {get;set;} public string tipoDocumento {get;set;} public string RazaoSocial {get;set;} public string NumeroDocumento {get;set;} public string Temp {get;set;} public list <Account> listAccPesquisa{get;set;} /********** construtor contructor ***********/ public AccountSearch_clt(ApexPages.StandardController controller) { } public void getAccounts(){ String stringComplemento = ''; string searchquery='SELECT name, id, Tipo_de_Documento__c, SiteNumber__c, RazaoSocial__c, NomeFantasia__c, '+ 'N_mero_do_Documento__c, CustomerNumber__c, Cia__c FROM Account '; if(PesquisaString != ''){ stringComplemento = ' WHERE name LIKE '+ '\'%' +PesquisaString+'%\''; } if(NomeFantasia != '' && NomeFantasia!=null){ if(stringComplemento!=''){ stringComplemento += ' and '; }else{ stringComplemento += ' where '; } stringComplemento += ' NomeFantasia__c LIKE '+ '\'' +NomeFantasia+'\''; } if(PesquisaCodCliente!= ''){ if(stringComplemento!=''){ stringComplemento += ' and '; }else{ stringComplemento += ' where '; } stringComplemento += ' CustomerNumber__c LIKE '+ '\'' +PesquisaCodCliente+'\''; } if(PesquisaCodEndereco!= ''){ if(stringComplemento!=''){ stringComplemento += ' and '; }else{ stringComplemento += ' where '; } stringComplemento += ' SiteNumber__c LIKE '+ '\'' +PesquisaCodEndereco+'\''; } if(cia!= ''){ if(stringComplemento!=''){ stringComplemento += ' and '; }else{ stringComplemento += ' where '; } stringComplemento += ' Cia__c LIKE '+ '\'' +cia+'\''; } if(tipoDocumento!= ''){ if(stringComplemento!=''){ stringComplemento += ' and '; }else{ stringComplemento += ' where '; } stringComplemento += ' Tipo_de_Documento__c LIKE '+ '\'' +tipoDocumento+'\''; } if(RazaoSocial!= ''){ if(stringComplemento!=''){ stringComplemento += ' and '; }else{ stringComplemento += ' where '; } stringComplemento += ' RazaoSocial__c LIKE '+ '\'' +RazaoSocial+'\''; } if(NumeroDocumento!= ''){ if(stringComplemento!=''){ stringComplemento += ' and '; }else{ stringComplemento += ' where '; } stringComplemento += ' N_mero_do_Documento__c LIKE '+ '\'' +NumeroDocumento+'\''; } searchquery = searchquery + stringComplemento; Temp=searchquery ; listAccPesquisa = Database.query(searchquery); } public void doSearch(){ getAccounts(); } }
All Answers
The "with sharing" prevents to access records that are not shared with the running user.
--
May the Force.com be with you!