You need to sign in to do that
Don't have an account?
Sami Shakith
Error: Compile Error: Initial term of field expression must be a concrete SObject: List<Price_Details__c> at line 48 column 17
Hi,
I am trying to develop a project for my learning purpose. I have created a two VF page and a controller class.
My Quote VF page
While saving this class it shows the error like this
Error: Compile Error: Initial term of field expression must be a concrete SObject: List<Price_Details__c> at line 48 column 17.
Please I need someone help.
I am trying to develop a project for my learning purpose. I have created a two VF page and a controller class.
My Quote VF page
<apex:page standardcontroller="Opportunity" extensions="QuoteController" sidebar="false" > <apex:form > <apex:pageBlock > <html> <body> <table> <tr> <apex:pageBlockSection > <td><table border="0" bgcolor="#00BFFF" > <tr><apex:inputField value="{!SearchCriteria.Operating_Model__c}"/></tr> <tr><apex:inputText label="Quantity" value="{!Quantity}"/> </tr> <apex:inputField value="{!SearchCriteria.partno__r.Type__c}" id="degreeLevel" onchange="assignDegreeLevel(this.value)"/> <apex:actionFunction name="assignDegreeLevel" action="{!filterApplicant}" reRender="program" immediate="true"> <apex:param name="degreeSelected" assignTo="{!degreeSelected}" value=""/> </apex:actionFunction> <tr><apex:commandButton value="Go" action="{!filterApplicant}"/> </tr> </table> </td> </apex:pageBlockSection> <apex:pageBlockSection rendered="{!GoShopping}"> <apex:commandLink action="{!GoToCart}" value="Go to Shopping Cart"/><br></br><br></br> <apex:outputLink value="/?id={!Opportunity.id}">Go Back</apex:outputLink> </apex:pageBlockSection> <td style="width:100%"><apex:pageBlockTable value="{!FilteredApplicants}" var="applicant"> <apex:column > <apex:inputCheckbox value="{!selected}"/> </apex:column> <apex:column value="{!applicant.Operating_Model__c}"/> <apex:column value="{!applicant.MSRP__c}"/> <apex:column value="{!applicant.Buying_Price__c}"/> <apex:column value="{!applicant.Type__c}"/> </apex:pageBlockTable> <apex:pageMessages id="error"></apex:pageMessages> </td></tr> </table> </body> </html> </apex:pageBlock> </apex:form> </apex:page>My QuoteController class
public with sharing class QuoteController { public boolean GoShopping{get;set;} public boolean GoToCart{get;set;} public boolean Selected{get;set;} public Integer Quantity{get;set;} public String degreeSelected{get;set;} public decimal NetAmount{get;set;} public decimal NetAmount1{get;set;} public Opportunity opp{get;set;} public List<Parts__c> types{get;set;} public List<Price_details__c> FilteredApplicants{get;set;} public list<Price_details__c> listPrice{get;set;} public Price_details__c SearchCriteria{get;set;} public String cid= ApexPages.currentPage().getParameters().get('id'); public QuoteController(ApexPages.StandardController controller) { SearchCriteria = new Price_details__c(); types = new list<Parts__c>(); types=[select type__c from parts__c]; GoShopping = false; NetAmount=0; } public void filterApplicant() { FilteredApplicants = new List<Price_details__c>(); FilteredApplicants = [SELECT Id, Name, Region__c, MSRP__c, Operating_Model__c, Buying_Price__c, QuantityStart__c,QuantityEnd__c,Type__c FROM Price_details__c WHERE Operating_Model__c =: SearchCriteria.Operating_Model__c and QuantityStart__c<=:Quantity and QuantityEnd__c>=:Quantity AND Type__c=:degreeSelected]; GoShopping=true; if(FilteredApplicants.size() == 0) { Apexpages.addMessage(new ApexPages.Message (ApexPages.Severity.INFO,''+'No records to Display')); } } public PageReference GoToCart() { Opp = new Opportunity(); listPrice = new list<Price_Details__c>(); listPrice = [select id, name, Buying_Price__c from price_details__c]; for(Price_details__c price: listPrice) { if(selected=true){ listPrice.Opportunity__c=Opp.Name; NetAmount=NetAmount+price.Buying_Price__c; netAmount1=NetAmount; system.debug('@@@@@'+NetAmount); } } pagereference ref; ref = new pagereference('/apex/ShoppingCart?id='+cid); ref.setredirect(true); return ref; } }ShoppingCart VF page
<apex:page StandardController="Opportunity" extensions="QuoteController"> <apex:form > <apex:pageBlock > <apex:pageBlockSection columns="1"> <apex:outputField label="User Name" value="{!opportunity.Name}"/> <apex:outputField label=" Account Name" value="{!Opportunity.AccountId}"/> <apex:outputField label="Email Id" value="{!Opportunity.Email__c}"/> <apex:outputLabel value="{!NetAmount}"></apex:outputLabel> </apex:pageBlockSection> </apex:pageBlock> </apex:form> Related price details for {!Opportunity.name}: <apex:relatedList list="Price_Details__r" /> </apex:page>
While saving this class it shows the error like this
Error: Compile Error: Initial term of field expression must be a concrete SObject: List<Price_Details__c> at line 48 column 17.
Please I need someone help.
But showing the same error. What shall i do?
listPrice is list .
listprice[0].Opportunity__c=Opp.id;
You'll need to do this:
price.Opportunity__c=Opp.id; is correct
In that i am facing 3 problems.
1st is it shows error while saving the class.
2nd is if i command that line and continue to save, its saved but the NetAmount is just adding single record.
3rd is even that single NetAmount value not displaying while redirecting for 2nd page.
Please give some solution. What mistakes i did in that.
{
if(selected=true){
price.Opportunity__c=Opp.id;
NetAmount=NetAmount+price.Buying_Price__c;
netAmount1=NetAmount;
system.debug('@@@@@'+NetAmount);
}
}
Update listprice;
pagereference ref;
ref = new pagereference('/apex/ShoppingCart?id='+cid);
ref.setredirect(false);
return ref;
}
update and set redirect
But this to has some problems. All the product detail records is adding as a line item for opportunity. And i am not getting the net amount.
You are not binding checkbox with records.
https://developer.salesforce.com/page/Wrapper_Class
If this answer helps you please mark it as best answer.
Hi Akshat ,
Thanks for your solution.
I tried in seperated VF page its worked. But combine the code in class its showing error.
Error: Compile Error: unexpected token: 'opportunity' at line 26 column 7
While saving it shows like this. Please tell me what should i do.