You need to sign in to do that
Don't have an account?
Meeta Khullar 5
System.QueryException exception
I have a visual force page that is build to do revenue recognition using custom object invoice and start object order. The form has an Account field that the user can look up the revenue based on the account. The problem that I'm having is that when the user put in the account that has 0 order the VF page throws 'System.QueryException' exception. I'm trying to use the try catch but it is still failing. Here is the code snip, the row that is highlighted in bold and underlined is the one that is causing the issue. Please suggest how do I resolve this issue.
public with sharing class RMSController{
// public List<Order> ord1 = new List<Order>();
public Date startDate {get; set;}
public Date endDate {get; set;}
public boolean renderSearch = false;
public string orderNumber{get;set;}
public string InvoiceNo {get;set;}
public String domain {get;set;}
public String accountId { get; set; }
public Order ord { set; }
public Order getOrd(){
if(accountId!= null)
return [select id,account.id,account.QAD_Domain__c from order where account.id = : accountId limit 1];
return null;
}
public with sharing class RMSController{
// public List<Order> ord1 = new List<Order>();
public Date startDate {get; set;}
public Date endDate {get; set;}
public boolean renderSearch = false;
public string orderNumber{get;set;}
public string InvoiceNo {get;set;}
public String domain {get;set;}
public String accountId { get; set; }
public Order ord { set; }
public Order getOrd(){
if(accountId!= null)
return [select id,account.id,account.QAD_Domain__c from order where account.id = : accountId limit 1];
return null;
}
Try to use something like this and see what it is returning in your debug logs in developer console so that you will be able to find your bug.
Hope this helps you!
If this helps you mark it as solved.
Thanks and Regards
Sandhya
<apex:pageBlockSectionItem >
<apex:outputLabel value="Account" for="theLookup"/>
<apex:inputField id="Account" value="{!ord.accountid}" label="Account">
<apex:actionSupport event="onchange" rendered="false">
<apex:param name="accountId" value="" assignTo="{!accountId}"/>
</apex:actionSupport>
</apex:inputField>
</apex:pageBlockSectionItem>
When I put your code in the controller I get the VisualforceArraylist.account error
public with sharing class RMSController{
// public List<Order> ord1 = new List<Order>();
public Date startDate {get; set;}
public Date endDate {get; set;}
public boolean renderSearch = false;
public string orderNumber{get;set;}
public string InvoiceNo {get;set;}
public String domain {get;set;}
public String accountId { get; set; }
//public Order ord { set; }
public List<Order> Ord { set; }
/*public Order getOrd(){
if(accountId!= null)
return [select id,account.id,account.QAD_Domain__c from order where account.id = : accountId limit 1];
return null;
}*/
public List<Order> getOrd(){
if(accountId!= null)
return [select id,account.id,account.QAD_Domain__c from order where account.id = : accountId limit 1];
return null;
}
Please suggest how do I fix this?
Regards,
Meeta