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.

  • So pls confrm my understanding. So in your first page you are selecting few product and redirect to another page. In this page Based on selected product you want to display product detail and opp line item custom field correct? – Ratan Paul Feb 13 '16 at 13:54
  • no, actually after a product name i'll show custom fields as inputfield after filling those field i wants to create record for each product in opportunityLineitem object so that i'll be displaying those records in related list of opportunitylineitem which is there in opportunity. – RAT__ Feb 13 '16 at 14:07

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}"/>
  • can we use pricebook entry object to fetch the details of products and its respective prices @RATAN – RAT__ Feb 13 '16 at 14:29
  • @RAT__ Can you please explain more what do you want ? – Ratan Paul Feb 13 '16 at 14:37
  • @RAT__ you can query like that SELECT Id, Name, PricebookEntryId, Product2Id FROM OpportunityLineItem WHERE Product2Id = '01t90000003IOQkAAO' and get the pricebook2Id – Ratan Paul Feb 13 '16 at 14:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.