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
veeru_pariveeru_pari 

Display output

Hi,
I want to display the output of the getsearch method in the below code in vf page so that if i select one pick list i should get the answer

public String selectedValue {get;set;}
public List<SelectOption> getUserType()
{
  List<SelectOption> options = new List<SelectOption>();   
   Schema.DescribeFieldResult fieldResult =FAQ__c.Users__c.getDescribe();
   List<Schema.PicklistEntry> ple = fieldResult.getPicklistValues();
     // options.add(new SelectOption('All','All'));
   for( Schema.PicklistEntry f : ple)
   {
      options.add(new SelectOption(f.getLabel(), f.getValue()));
   }   
   return options;
}
public List<FAQ__c> getSearch(){
        System.debug('====selectedValue===='+selectedValue); // You will get the Selected Value here
       
        List<FAQ__c> temp = new List<FAQ__c>();
     String queryString;
   if(selectedValue=='AllUsers')
   queryString='SELECT Users__c,Question__c,Answer__cfrom FAQ__c WHERE Users__c =AllUsers';
   else if(selectedValue=='InternalUsers')
   queryString='SELECT Users__c,Question__c,Answer__c from FAQ__c WHERE Users__c =InternalUsers';
   else if(selectedValue=='ExternalUsers')
queryString='SELECT Users__c,Question__c,Answer__c from FAQ__c WHERE Users__c =ExternalUsers';
      
   temp = Database.query(queryString);
  
      return temp;
      }
DevADSDevADS
Hey Veeru,

Your querystring is wrong, so that It will return null records, Put escape characters.
Correct your querystring to queryString='SELECT Users__c,Question__c,Answer__cfrom FAQ__c WHERE Users__c = \' AllUsers\' ';
Hope this will help. Happy Coding!!

Sonam_SFDCSonam_SFDC
You can display the content from the search using the code similar to the one mentioned in the link below:
http://www.mindfiresolutions.com/Salesforce-Custom-Picklist-in-VisualForce-Page-1480.php

veeru_pariveeru_pari
Hi Amit, How can i display that result of *queryString='SELECT Users__c,Question__c,Answer__cfrom FAQ__c WHERE Users__c = \' AllUsers\' '; *in vf page? Thanks Veeraiah
veeru_pariveeru_pari
How can i display that result of *queryString='SELECT Users__c,Question__c,Answer__cfrom FAQ__c WHERE Users__c = \' AllUsers\' '; *in vf page? When i am displaying wit output panel i am getting nullpointer exception On Fri, Jan 10, 2014 at 3:33 PM, veeru chowdary
DevADSDevADS
Use apex:pageblock table or apex:repeat.
veeru_pariveeru_pari
Hi Amit I am getting the Null pointerexception Thanks
veeru_pariveeru_pari
Hi Amit, I am getting this error while using the below code in vf(System.NullPointerException: Argument 1 cannot be null ) public class FAQCu { public String selectedValue {get;set;} public List getUserType() { List options = new List(); Schema.DescribeFieldResult fieldResult =FAQ__c.Users__c.getDescribe(); List ple = fieldResult.getPicklistValues(); // options.add(new SelectOption('All','All')); for( Schema.PicklistEntry f : ple) { options.add(new SelectOption(f.getLabel(), f.getValue())); } return options; } public List getSearch(){ System.debug('====selectedValue===='+selectedValue); // You will get the Selected Value here List temp = new List(); String queryString; if(selectedValue=='AllUsers') queryString='SELECT Users__c,Question__c,Answer__cfrom FAQ__c WHERE Users__c = \'AllUsers\' '; else if(selectedValue=='InternalUsers') queryString='SELECT Users__c,Question__c,Answer__cfrom FAQ__c WHERE Users__c = \'InternalUsers\' '; else if(selectedValue=='ExternalUsers') queryString='SELECT Users__c,Question__c,Answer__cfrom FAQ__c WHERE Users__c = \'InternalUsers\' '; */Line 26/temp = Database.query(queryString);* return temp; } } *VF* *apex:page controller="FAQCu" id="theRepeat">
Thanks in advance* On Fri, Jan 10, 2014 at 4:00 PM, veeru chowdary
DevADSDevADS
Hey, you are adding 'All' in Selectoption list & comparing with string 'AllUsers'.

options.add(new SelectOption('All','All'));
if(selectedValue=='AllUsers') queryString='SELECT Users__c,Question__c,Answer__cfrom FAQ__c WHERE Users__c = \'AllUsers\' ';
veeru_pariveeru_pari
No Amit , please see the line *options.add(new SelectOption('All','All')); * in that code is commented.
Sonam_SFDCSonam_SFDC
System.NullPointerException: Argument 1 cannot be null is sen when a variable is defined and is not initialize a value.

Please initialise the default value to selectedValue in the contructor:  public String selectedValue {get;set;}
veeru_pariveeru_pari
Hi , I'd like to add you to my professional network on LinkedIn. - veeraiah Accept: https://www.linkedin.com/e/v2?e=cdpkqm-hxn5ax8d-64&a=preRegInvite&tracking=eml-guest-invite-cta&ek=invite_guest&invitationID=5894776469669818369&sharedKey=5H5Kie5a You are receiving Invitation emails. Unsubscribe here: https://www.linkedin.com/e/v2?e=cdpkqm-hxn5ax8d-64&t=uns&tracking=eml-guest-invite-unsubscribe&ek=invite_guest&id=20061∣=-1&aid=iuehc9r3r0sm6r3&eid=cdpkqm-hxn5ax8d-64&email=dhv77uo5skjrcjsv%2Ez6sqms2zbaawgny5%40uzypqpmyfdupug89%2Exz1r%2Ef-55kkmai%2Ena10%2Echatter%2Esalesforce%2Ecom Learn why we included this at the following link: http://www.linkedin.com/e/v2?e=cdpkqm-hxn5ax8d-64&a=customerServiceUrl&ek=invite_guest&articleId=4788 © 2014, LinkedIn Corporation. 2029 Stierlin Ct. Mountain View, CA 94043, USA
veeru_pariveeru_pari
Hi , I'd like to add you to my professional network on LinkedIn. - veeraiah Accept: https://www.linkedin.com/e/v2?e=-4zjzf3-hxn5axfp-3f&a=preRegInvite&tracking=eml-guest-invite-cta&ek=invite_guest&invitationID=5894776476695289856&sharedKey=t7DNa18F You are receiving Invitation emails. Unsubscribe here: https://www.linkedin.com/e/v2?e=-4zjzf3-hxn5axfp-3f&t=uns&tracking=eml-guest-invite-unsubscribe&ek=invite_guest&id=20061∣=-1&aid=iuehc9r3r0sm6r3&eid=-4zjzf3-hxn5axfp-3f&email=0-17p1heony5gpq9%2E8688e2cjnnhsy30x%40vn2gb6pw6eooqa6e%2E7ezrem2%2Ef-55kkmai%2Ena10%2Echatter%2Esalesforce%2Ecom Learn why we included this at the following link: http://www.linkedin.com/e/v2?e=-4zjzf3-hxn5axfp-3f&a=customerServiceUrl&ek=invite_guest&articleId=4788 © 2014, LinkedIn Corporation. 2029 Stierlin Ct. Mountain View, CA 94043, USA
veeru_pariveeru_pari
Hi , I'd like to add you to my professional network on LinkedIn. - veeraiah Accept: https://www.linkedin.com/e/v2?e=qu91ip-hxn5ax3a-50&a=preRegInvite&tracking=eml-guest-invite-cta&ek=invite_guest&invitationID=5894776470290579456&sharedKey=FjUOoo6s You are receiving Invitation emails. Unsubscribe here: https://www.linkedin.com/e/v2?e=qu91ip-hxn5ax3a-50&t=uns&tracking=eml-guest-invite-unsubscribe&ek=invite_guest&id=20061∣=-1&aid=iuehc9r3r0sm6r3&eid=qu91ip-hxn5ax3a-50&email=0-2efz7219n32n05%2E0yvx982kwdhvmdgw%406tkrraas02eycq5a%2Eb6iajh4%2Ef-55kkmai%2Ena10%2Echatter%2Esalesforce%2Ecom Learn why we included this at the following link: http://www.linkedin.com/e/v2?e=qu91ip-hxn5ax3a-50&a=customerServiceUrl&ek=invite_guest&articleId=4788 © 2014, LinkedIn Corporation. 2029 Stierlin Ct. Mountain View, CA 94043, USA