function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
miteshsuramiteshsura 

adding Product Bundle to Quote

Hello! All,

 

I have a custom object: Product Bundle, as name suggests, they have more than one Product/Service attached to it. 

And in my opportunity section I can add both individual line items and/or Product Bundle - this was the hard part. 

Apex and VF helped. 

 

So now coming to the quotes, how can I add this custom object to my quote, I want each Bundle Item to be seen in a different section under quote. Has anyone thought/worked on it. 

 

Thanks for viewing this thread...

sfdcfoxsfdcfox

To make the bundles appear as separate sections, you'll need two classes: a Bundle class and an Item class. Such a class might appear in an extension, as follows:

 

 

public class QuoteExtension {
  private Id quoteId;
  public QuoteExtension(ApexPages.StandardController controller) {
    quoteId = controller.getId();
  }
  public class Bundle {
    public Bundle(String Name) {
      this.Name = Name;
      this.Items = new List<Item>();
    }
    public String Name { get; set; }
    public List<Item> Items { get; set; }
  }
  public class Item {
    public Item(String Name, String ProductCode) {
      this.Name = Name;
      this.ProductCode = ProductCode;
    }
    public String Name { get; set; }
    public String ProductCode { get; set; }
  }
  public List<Bundle> getBundles() {
    List<Bundle> bundles = new List<Bundle>();
    for(Bundle__c bundle:
       [select id,name,
           (select id,name from Products__r) from Bundle__c
            where Quote__c = :quoteId]) {
      Bundle tempBundle = new Bundle(bundle.name);
      for(Product__c product:bundle.Products__r)
        tempBundle.items.add(new Item(product.name,product.ProductCode__c));
      bundles.add(tempBundle);
    }
    return bundles;
  }
}

 

To use this in Visualforce, create a page that will display the quote information, then display the bundles. That code might appear as follows:

 

 

<apex:page standardController="Quote__c" extensions="QuoteExtension">
  <apex:detail/>
  <apex:repeat value="{!bundles}" var="bundle">
    <apex:pageBlock title="{!bundle.name}">
      <apex:dataTable width="100%" value="{!bundle.items}" var="item">
        <apex:column headerValue="Name" value="{!item.name}"/>
        <apex:column headerValue="Product Code" value="{!item.productcode}"/>
      </apex:dataTable>
    </apex:pageBlock>
  </apex:repeat>
</apex:page>

Of course, you'll want to adjust the fields that you need, specific formatting, etc. I do hope that this framework gives you a good starting point that you can work from.

 

miteshsuramiteshsura

Thanks sfdcfox.

 

Not sure if I explained it correctly. Here is what  I am trying to achieve..

 

1. I can already display Bundles as seperate section on Opportunities using Apex and VF.

 

2. I have enabled new Quote feature on Sandbox.

 

3. What I need is when user hits "New Quote" button under Quote related section in Opportunities, I want the quote to show both Individual line items as well as Bundles for that opportunity. Also both individual line items and Bundles should be seen when User hits Generate PDF from Quote page.

 

For now SF provides the functionality for Line Items, not sure how to extend it show Custom Bundle Object??

Can this be achieved without building custom Quote object??