You need to sign in to do that
Don't have an account?
HTANIRS
custom controller record id is displaying Error
Hi Friends,
I have created a custom controller and a vf page and when I run the vf page I am getting List has no Rows error.
Kindly needed your help to resolve this issue.
Below is my class and VF code.
Thanks in Advance.
I have created a custom controller and a vf page and when I run the vf page I am getting List has no Rows error.
Kindly needed your help to resolve this issue.
Below is my class and VF code.
Apex Class: public class quoteController { private final SBQQ__Quote__c quotePDF; private final SBQQ__Quote__c quoteOpp; private final SBQQ__Quote__c quoteProd; public quoteController() { // Query for QuoteLineItem quotePDF = [SELECT Id, SBQQ__Account__r.Name, SBQQ__BillingCity__c, SBQQ__BillingName__c, SBQQ__ShippingCity__c, SBQQ__ShippingName__c, (Select Id, SBQQ__ProductName__c, SBQQ__Quantity__c, SBQQ__Description__c, SBQQ__ListPrice__c, SBQQ__NetTotal__c from SBQQ__LineItems__r) FROM SBQQ__Quote__c WHERE Id = :ApexPages.currentPage().getParameters().get('id')]; // Query for Quote Opportunity quoteOpp = [SELECT Id, SBQQ__Opportunity2__r.Vehicle_Make__c, SBQQ__Opportunity2__r.Rego_Fleet_Number__c, SBQQ__Opportunity2__r.Vin_Number__c, SBQQ__Opportunity2__r.Odometer__c, SBQQ__Opportunity2__r.Vehicle_Model__c FROM SBQQ__Quote__c WHERE Id = :ApexPages.currentPage().getParameters().get('id')]; // Query for Quote Product quoteProd = [SELECT Id, (Select Id, SBQQ__Product__r.Refrigeration_Gas__c from SBQQ__LineItems__r) FROM SBQQ__Quote__c WHERE Id = :ApexPages.currentPage().getParameters().get('id')]; } public SBQQ__Quote__c getquotePDF(){ return quotePDF; } public SBQQ__Quote__c getquoteOpp(){ return quoteOpp; } public SBQQ__Quote__c getquoteProd(){ return quoteProd; } }
VF Page: <apex:page controller="quoteController" tabStyle="SBQQ__Quote__c" showHeader="false" sidebar="false" standardStylesheets="false" applyBodyTag="false" applyHtmlTag="false"> <html> <body> <apex:pageBlock > <apex:pageBlockTable columns="5" border="1" cellspacing="0" cellPadding="5" width="95%" value="{!quotePDF}" var="myOrder"> <apex:column value="{!myOrder.SBQQ__Account__r.Name}" /> <apex:column value="{!myOrder.SBQQ__BillingCity__c}" /> <apex:column value="{!myOrder.SBQQ__BillingName__c}" /> <apex:column headerValue="QTY"> <apex:outputText value=" " /> </apex:column> <apex:column value="{!myOrder.SBQQ__ShippingCity__c}" /> </apex:pageBlockTable> </apex:pageBlock> <p class="onepointfive"/> <apex:pageBlock > <apex:pageBlockTable columns="5" border="1" cellspacing="0" cellPadding="5" width="95%" value="{!quoteOpp}" var="quoteOpp"> <apex:column value="{!quoteOpp.SBQQ__Opportunity2__r.Vehicle_Make__c}" /> <apex:column value="{!quoteOpp.SBQQ__Opportunity2__r.Rego_Fleet_Number__c }" /> <apex:column value="{!quoteOpp.SBQQ__Opportunity2__r.Vin_Number__c }" /> <apex:column headerValue="QTY"> <apex:outputText value="{!quoteOpp.SBQQ__Opportunity2__r.Odometer__c}" /> </apex:column> <apex:column value="{!quoteOpp.SBQQ__Opportunity2__r.Vehicle_Model__c}" /> </apex:pageBlockTable> </apex:pageBlock> <p class="onepointfive"/> <apex:pageBlock > <apex:pageBlockTable columns="5" border="1" cellspacing="0" cellPadding="5" width="100%" value="{!quotePDF.SBQQ__LineItems__r}" var="OrderItems" > <apex:column headerValue="Product Name"> <apex:outputField value="{!OrderItems.SBQQ__ProductName__c}"/> </apex:column> <apex:column headerValue="PartNumber"> <apex:outputField value="{!OrderItems.SBQQ__Quantity__c}"/> </apex:column> <apex:column headerValue="Item Type"> <apex:outputField value="{!OrderItems.SBQQ__Description__c}"/> </apex:column> <apex:column headerValue="Option Type"> <apex:outputText value="{!OrderItems.SBQQ__ListPrice__c}"/> </apex:column> <apex:column headerValue="Value"> <apex:outputField value="{!OrderItems.SBQQ__NetTotal__c}"/> </apex:column> </apex:pageBlockTable> </apex:pageBlock> <p class="onepointfive"/> <apex:pageBlock > <apex:pageBlockTable columns="5" border="1" cellspacing="0" cellPadding="5" width="100%" value="{!quoteProd.SBQQ__LineItems__r}" var="prod" > <apex:column headerValue="Refrigeration Gas"> <apex:outputField value="{!prod.SBQQ__Product__r.Refrigeration_Gas__c}"/> </apex:column> --> </apex:pageBlockTable> </apex:pageBlock> <p class="onepointfive"/> </body> </html> </apex:page>
Thanks in Advance.
You can have these in Constructer.
All Answers
One of above query is not returning any number of records. The error "List has no rows occurs when query doesn't return any rows.
While a SELECT normally returns an array/list, these statements are using the shorthand syntax that assumes only one row is returned.
What’s not obvious is that it also assumes that exactly one row is returned!
You could do something like this below.
Same goes for others as well. And then Return the list on Page.
Mark this as your best answer to help others if this solves your problem.
Regards,
Avishek
Thanks for your reply. May I know where should I implement this change. In Constructor or PageReference.
Thanks
You can have these in Constructer.