Skip to main content

Hi, 

 

I am completely new to developing and im trying to create a custom quote for the company i work at.

I managed to find code i could use to display the related opportunity line items but for it displays the line item with the opportunity name before it.

Opportunity name appearing before opportunity products line item name on pdf

Below is the code

public class CreateQuoteClass {    

public String opportunitystringId {get;set;}

public List<Opportunity> opportunityList {get;set;}

public List<quotewrapper> quotewrapperlist {get;set;}

public List<OpportunityLineItem> oliList{get;set;}

    

    public class quotewrapper

    {

        public Boolean isChecked {get;set;}

        public OpportunityLineItem oliresult {get;set;}

        

        public quotewrapper(Boolean isChecked, OpportunityLineItem oliresult)

        {

            This.isChecked = isChecked;

            This.oliresult = oliresult;

        } 

    }   

    

    public CreateQuoteClass(ApexPages.StandardController controller)

    {

        try{

            quotewrapperlist = new List<quotewrapper>();

            opportunitystringId  = ApexPages.CurrentPage().getparameters().get('Id');

            

            if(opportunitystringId!=null)

            {

                opportunityList = [SELECT Id,Name,CloseDate,AccountId,Pricebook2Id from Opportunity WHERE Id =:opportunitystringId];

                oliList = [Select Id,Name,Quantity,OpportunityId,UnitPrice,Product2Id,PricebookentryId,TotalPrice from OpportunityLineItem WHERE OpportunityId =:opportunitystringId];

            }

            

            if(oliList.size()>0)

            {

                for(OpportunityLineItem olObj:oliList)

                {

                    quotewrapper qobj =  new quotewrapper(false, olObj);

                    quotewrapperlist.add(qobj);

                }

            }

        }

        catch(Exception e)

        {

            System.debug('The following exception has occurred: ' + e.getMessage());

        }

        

    }

    

}

Visualforce Page

        <apex:pageBlock >

            <apex:pageBlockTable var="qi" value="{!quotewrapperlist}" id="quoteitem">

                <apex:column headerValue="Additional Options" value="{!qi.oliresult.name}"/>

                <apex:column headerValue="Quantity" value="{!qi.oliresult.Quantity}"/>

                <apex:column headerValue="Sales Price" value="{!qi.oliresult.Unitprice}"/>

                <apex:column headerValue="Total Price" value="{!qi.oliresult.TotalPrice}"/>

            </apex:pageBlockTable>

        </apex:pageBlock><br/><br/>

    
1 respuesta
  1. 26 ene 2022, 08:01
    Hi Breandan,

    I dont see the code for displaying the opportunity data in the VF page. Is it total visual force page . Can you share the total visual force page so we can look into it.

    Thanks,

     
0/9000