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
Meeta Khullar 5Meeta Khullar 5 

Get method not getting data from the Picklist field

I have a visualforce page that has a picklist field "QAD Domain". This is the coding to display the field

<apex:pageBlockSectionItem >
                 <apex:outputLabel value="QAD Domain"/>
                 <apex:inputField id="QADDomain" value="{!ord.account.QAD_Domain__c}">
                       <apex:actionSupport event="onchange" rendered="false">                             
                              <apex:param name=" {!domain} " value="{!ord.account.QAD_Domain__c}" assignTo="{!domain}"/> 
                       </apex:actionSupport>
                 </apex:inputField>
           </apex:pageBlockSectionItem>   



I have a controller that does the get and set method. When I run the debug log I see there is no value that is passed to the controller for the domain. Can someone point me what correction I need to make to the code in order to get the selected value in the controller.

public String  domain {get;set;}
if(domain != null)
                  mainSoql = mainSoql + ' and  Order_Product__r.order.account.QAD_Domain__c = \''+ domain + '\'';

String mainSoql = 'select id,'+
                    'Name,'+
                   'Start_Date__c,'+
                    'End_Date__c,'+
                    'Order_Product__r.UnitPrice,'+            
                    'Order_Product__r.id,'+
                    'Order_Product__r.order.account.QAD_Domain__c,'+
                    'Order_Product__r.order.accountid,'+
                    'Invoice__r.Orders__r.Name'+
                    ' from Invoice_Line_Items__c where Invoice__r.Status__c= \''+
                    invoiceStatus+'\' and  Unit_Price__c > 0';

 
Priyanka S 27Priyanka S 27
Change the following line,
<apex:param name=" {!domain} " value="{!ord.account.QAD_Domain__c}" assignTo="{!domain}"/> 
to 
<apex:param name="domainName" value="{!ord.account.QAD_Domain__c}" assignTo="{!domain}"/> 

In your controller side you can directly access the value of the domain field in Account as below,

if(ord.account.QAD_Domain__c != null){
mainSoql = mainSoql + ' and  Order_Product__r.order.account.QAD_Domain__c = \''+ ord.account.QAD_Domain__c+ '\'';
String mainSoql = 'select id,'+
                    'Name,'+
                   'Start_Date__c,'+
                    'End_Date__c,'+
                    'Order_Product__r.UnitPrice,'+            
                    'Order_Product__r.id,'+
                    'Order_Product__r.order.account.QAD_Domain__c,'+
                    'Order_Product__r.order.accountid,'+
                    'Invoice__r.Orders__r.Name'+
                    ' from Invoice_Line_Items__c where Invoice__r.Status__c= \''+
                    invoiceStatus+'\' and  Unit_Price__c > 0';
}

Let me know if you have any questions.

Thanks,
Priyanka S
Meeta Khullar 5Meeta Khullar 5
Thanks Priyanka for the reply: I tried both the option, it is still not working. The problem is the field is not capturing the value that the user is picking in the QAD Domain picklist filed. Thus no value is passed to the domain {get;set;}. If I make it a text field and type in the value then it works but since this is a picklist field we want to keep it that way. 1. Updated the VF Page and rant he debug log it is still showing the value to be null . 2. Updated the controller, now it is giving “System.NullPointerException: Attempt to de-reference a null object “ if(ord.account.QAD_Domain__c != null){ mainSoql = mainSoql + ' and Order_Product__r.order.account.QAD_Domain__c = \''+ ord.account.QAD_Domain__c+ '\''; Thanks, Meeta