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 

Error while displaying output

I am getting the nullpointer while displaying the controller code in vf using output panel .How can i resolve this

public class FAQCu {
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__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\' ';
temp = Database.query(queryString);
  
      return temp;
      }
    }
Vf page

<apex:page controller="FAQCu">
<apex:form >

<apex:selectList id="users" value="{!selectedValue}" size="1" required="true">
  <apex:selectOptions value="{!userType}"/>
</apex:selectList>
</apex:form>
</apex:page>

In the above vf where and what tags should i write to display theoutput?Please help on this

Thanks

Ashish_SFDCAshish_SFDC
Hi Veeru, 


When are you getting the error? is it run time?

Can you tell on which line you are getting the error and the complete error message if possible.


Regards,
Ashish 



veeru_pariveeru_pari
The error is in vf i hope the error is like this (Visualforce ErrorSystem.NullPointerException: Argument 1 cannot be null Class.FAQCu.getSearch: line 26, column 1 ) The 26th line is below 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\' '; *26//temp = Database.query(queryString);* *Thanks*
Ashish_SFDCAshish_SFDC
Hi Veeru, 

See the suggesstions given in the below posts and mark the posts as Solved if the suggesstions solve the issue, 

https://developer.salesforce.com/forums/ForumsMain?id=906F00000009Dc5IAE

https://developer.salesforce.com/forums/ForumsMain?id=906F00000009DgMIAU

Regards,
Ashish
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=ojj6qn-hxn5ax1w-6k&a=preRegInvite&tracking=eml-guest-invite-cta&ek=invite_guest&invitationID=5894776469128753152&sharedKey=c8usCxS8 You are receiving Invitation emails. Unsubscribe here: https://www.linkedin.com/e/v2?e=ojj6qn-hxn5ax1w-6k&t=uns&tracking=eml-guest-invite-unsubscribe&ek=invite_guest&id=20061∣=-1&aid=iuehc9r3r0sm6r3&eid=ojj6qn-hxn5ax1w-6k&email=150nq5nbf490c66a%2Ehybg9zoncga22nbt%40hrv12kpgo172wvyw%2E4abgu%2Ef-55kkmai%2Ena10%2Echatter%2Esalesforce%2Ecom Learn why we included this at the following link: http://www.linkedin.com/e/v2?e=ojj6qn-hxn5ax1w-6k&a=customerServiceUrl&ek=invite_guest&articleId=4788 © 2014, LinkedIn Corporation. 2029 Stierlin Ct. Mountain View, CA 94043, USA