You need to sign in to do that
Don't have an account?
foodrunner
Custom Controller Error:
I am working on a visualforce page customizing the quote page layout with the quote line items. I am adapting the script from the Creating Compount Views turtorial on the wiki.
I am recieving the following error message:
Error: Compile Error: Return value must be of type: LIST<Quote> at line 9 column 9
Below is my controller code:
public class MyConsoleController { public MyConsoleController() { } public Quote selectedQuote { get; set; } public Quote[] getQuote() { return [SELECT id, Name, QuoteNumber, Created_Date__c, quote.Opportunity.AccountId, Quote_Line_Item__c, Grand_Total__c,BillingAddress__c, BillingAddress2__c FROM Quote where id = :ApexPages.currentPage().getParameters().get('id')]; } public QuoteLineItem[] getQuoteLineItems() { return [SELECT Id, PriceBookEntry.name, Quote__r.Grand_Total__c, QuoteID, Quantity, Quote_Item_Number__c, TotalPrice, ListPrice FROM QuoteLineItem WHERE QuoteId = :ApexPages.currentPage().getParameters().get('Id') order by Quote_Item_Number__c Asc];} }
My questions:
1. What am I doing wrong in this controller?
2. What needs to be changed?
Thank you
Hi,
Replace your getQuote() function with the following:
public Quote getQuote()
{
return [SELECT id, Name, QuoteNumber, Created_Date__c, quote.Opportunity.AccountId, Quote_Line_Item__c,
Grand_Total__c,BillingAddress__c, BillingAddress2__c FROM Quote where id = :ApexPages.currentPage().getParameters().get('id')];
}
The Query which you are using will return only one record, so you don't need to use return type as an array(Quote[]).
Shweta
Salesforce Developer Support
If my answer solved your question, please mark it solved so I can help as many community members as possible!
All Answers
Hi,
Replace your getQuote() function with the following:
public Quote getQuote()
{
return [SELECT id, Name, QuoteNumber, Created_Date__c, quote.Opportunity.AccountId, Quote_Line_Item__c,
Grand_Total__c,BillingAddress__c, BillingAddress2__c FROM Quote where id = :ApexPages.currentPage().getParameters().get('id')];
}
The Query which you are using will return only one record, so you don't need to use return type as an array(Quote[]).
Shweta
Salesforce Developer Support
If my answer solved your question, please mark it solved so I can help as many community members as possible!
Thank you for the reply. Unfortunately, I enter the new code to submit the following completed code
I recieve the following error:
Similar, but different.
Thank you for the solution. I found that I had downloaded a class named Quote from one of the tutorials, which was causing the problem.