You need to sign in to do that
Don't have an account?
fullvalue
Maps and Visualforce
Hi I'm wondering if someone can help me. I just started using Visualforce. Here is the situation.
I am trying to display opportunity line items with a job number associated to them. The association is through opportunity.
Opportunity parent of Opportunity Line Items
Opportunity parent of Project
I need to display opportunity line items with a field on the Project. I have created a map with the data but don't know how to display it in a visualforce page.
Here is the code to produce the map.
Here is the visualforce page. I got this to work with products but I need to display Job Number so therefore need to do something with the map.
Maybe there is a better way of doing this.
Any help would be great. Thanks!
I am trying to display opportunity line items with a job number associated to them. The association is through opportunity.
Opportunity parent of Opportunity Line Items
Opportunity parent of Project
I need to display opportunity line items with a field on the Project. I have created a map with the data but don't know how to display it in a visualforce page.
Here is the code to produce the map.
Code:
private set<ID> opptIds = new set<ID>(); private List<OpportunityLineItem> products = new List<OpportunityLineItem>(); private Map<ID,Project__c> opptproj = new Map<ID,Project__c>(); private Map<String,OpportunityLineItem> jnoli = new Map<String,OpportunityLineItem>(); for (SFDC_Project__c p : [SELECT Opportunity__c from Project__c where Branch__c = :branch]) { opptproj.put(p.Opportunity__c,p); opptIds.add(p.Opportunity__c); } products = [select Quantity, PricebookEntry.Product2.ProductCode,OpportunityId from OpportunityLineItem where OpportunityId in :opptIds]; for (Integer i = 0; i <products.size(); i++) { jnoli.put(opptproj.get(products[i].OpportunityId).Job_Number__c,products[i]); }
Here is the visualforce page. I got this to work with products but I need to display Job Number so therefore need to do something with the map.
Code:
<apex:repeat value="{!products}" var="product"> {!product.PricebookEntry.Product2.ProductCode} {!product.Quantity} <br/> <br/> </apex:repeat>
Maybe there is a better way of doing this.
Any help would be great. Thanks!
public class job {
public string jobnumber { get; set; }
public product2 product { get; set ; }
// add a constructor...
}
then you can construct a list of these, and you will need a getter for that list as well
public list<job> myJobs { get; set; }
now you can loop thru the myJobs list, and access the product and the job number of each
creating these wrapper classes is very common, they constitute your data model.