[SalesForce] To display two fields from two different objects in a single column of a table & creating new records with the help of them

i am trying To display two fields from two different objects in a single column of a table & creating new records with the help of them.
actually i am trying to create a customize product line item visualforce page almost similar to the standard one, so here i need to add the products with some more information so for that i have created few more fields in opportunity line item, i have already created the selct product page in which i am selecting the products and the i am redirecting to the next page with those selected productn so now on this page i'll be writing a wrapper class which will help me to show these products with opportunity line item custom fields that i need to fill on this page but after filling them how i can create a records containing table products with corresponding values in opportunity line item. plz someone help me out.

Best Answer

Create a wrapper class with product and new OLI

So you can bind the value using apex:inputField in VF page. And get the all list in controller and then you can create OLI

List<wrapProduct2OLI> lstWarpper = new List<wrapper>();

public class wrapProduct2OLI {
        public Product2 pro {get; set;}
        public OpportunityLineItem objOLI {get; set;}

        public wrapProduct2OLI(Product2 p) {
            pro = p;
            objOLI = new OpportunityLineItem();
        }
}

IN VF Page

<apex:pageBlockTable value="{!lstWarpper}" var="wrapper" >
<apex:column >
    <apex:outputField value="{!wrapper.pro.Name}"/>
    <apex:inputField value="{!wrapper.objOLI.CustomField__c}"/>
</apex:column>
</apex:pageBlockTable>
Related Topic