1

Can any help me out with the Error in visual force page :

Error as :

javax.faces.FacesException: core.apexpages.exceptions.ApexPagesDeveloperException: Map key BXRC-25E4000-F-04 not found in map

In a table i would like to display the data for the previous and current year.

This is the Table (expected output):

 ProductName         Year       Q1       Q2   Q3    Q4       Total
 BXRC-25e4000-F-04  2014       100     200   300   400       1000 
                    2015       100                            100  
 BXRC-25e4000-F-23  2014       200                 200        400
                    2015       300                            300
 Subtotal ------------         700     200   300   600       1800

But i get the o/p as:

ProductName         Year       Q1       Q2   Q3    Q4       Total
 BXRC-25e4000-F-04  2014       500     200   300   400       1400 

 BXRC-25e4000-F-23  2014       200                 200        400

Subtotal ------------          700     200   300   600       1800

When i use the condition

if ((monthText == 'Jan' || monthText == 'Feb' || monthText == 'Mar')&&(year==previousyear))

i get the previous year data .

But when i use the condition for the current year ,it does not works ,throws an error.

if ((monthText == 'Jan' || monthText == 'Feb' || monthText == 'Mar')&&(year==previousyear ||year==currentyear))

or

if ((monthText == 'Jan' || monthText == 'Feb' || monthText == 'Mar')&&(year==currentyear))

Code :

public with sharing class QuoteContentController {
    public Map < String, Decimal > PartMap {get;set;}
    public Map < string, Decimal > Quarter1 {get;set;}  
    public Map < string, Decimal > Quarter2 {get;set;}  
    public Map < string, Decimal > Quarter3 {get;set;}  
    public Map < string, Decimal > Quarter4 {get;set;}  
    public Map < string, Decimal > Amount1 {get;set;}  
    public Map < string, Decimal > Amount2 {get;set;}  
    public Map < string, Decimal > Amount3 {get;set;}  
    public Map < string, Decimal > Amount4 {get;set;}  
    public Competitor__c com {get;set;}  
    public gmod__Opportunity_Forecast__c opflist {get;set;}  
    public Id qId {get;set;}  
    Public string all {get;set;}  
    public integer previousyear{get;set;}
    public integer currentyear{get;set;}


    Public QuoteContentController() {}
    Public QuoteContentController(ApexPages.StandardController controller) {
        qId = Apexpages.currentPage().getparameters().get('Id');
        previousyear = date.today().year()-1;
        currentyear = date.today().year();
    }

   Public List<wrapperClass> disp_list {get;set;}{
        disp_list = new list < wrapperclass > ();
        //Query all the list     
        List < Quote > q = [select id, Name, QuoteNumber, Effective_Date__c, Comments__c, Quote.Opportunity.id,
                                    Quote.Opportunity.Probability, Quote.Opportunity.AccSegment__c, 
                                    Quote.Opportunity.AccApplication__c, Quote.Opportunity.Persona__c, Quote.Opportunity.Region__c
                                    from Quote where id = : apexpages.currentpage().getparameters().get('id')];
        Opportunity opp = [select id, Name, (select id, Quantity, product2id from OpportunityLineItems), 
                                probability, AccSegment__c 
                                from Opportunity where opportunity.Id = : q[0].opportunity.id LIMIT 1];
        List < gmod__Opportunity_Forecast__c > opflist = [ Select id, Name, gmod__opportunity__r.id, gmod__Quantity__c, gmod__Price__c,
                                                            gmod__Month__c, gmod__date__c, gmod__Quarter__c, gmod__Amount__c, Actual_Price__c, 
                                                            gmod__Year__c, gmod__Month_Text__c, Forecast_Date__c, gmod__Product__r.Name, 
                                                            gmod__opportunity__r.name from gmod__Opportunity_Forecast__c 
                                                            WHERE gmod__Product__c != null and gmod__opportunity__r.id = : opp.id 
                                                            Order BY  gmod__Product__r.Name,gmod__Year__c, gmod__Month__c asc];
        //Iterate through each list to extract the values and add it to the custom wrapper data type  

        PartMap = new Map < String, Decimal > ();
        Quarter1 = new Map < String, Decimal > ();
        Quarter2 = new Map < String, Decimal > ();
        Quarter3 = new Map < String, Decimal > ();
        Quarter4 = new Map < String, Decimal > ();
        Amount1 = new Map < String, Decimal > ();
        Amount2 = new Map < String, Decimal > ();
        Amount3 = new Map < String, Decimal > ();
        Amount4 = new Map < String, Decimal > ();

        for (gmod__Opportunity_Forecast__c oppforecast: opflist) {

            String prodName = oppforecast.gmod__Product__r.Name;
            String monthText = oppforecast.gmod__Month_Text__c;
            Integer year = Integer.valueof(oppforecast.gmod__Year__c);
            Integer previousyear = date.today().year()-1;
            Integer currentyear = date.today().year();


            Map<String, Decimal> quarterMap;
            Map<String, Decimal> amountMap;

            if ((monthText == 'Jan' || monthText == 'Feb' || monthText == 'Mar')&&(year==previousyear  )){
                quarterMap = Quarter1;
                amountMap = Amount1;
            if (quarterMap.containskey(prodName)) {
                quarterMap.put(prodName, quarterMap.get(prodName) + oppforecast.gmod__Quantity__c);
                amountMap.put(prodName, amountMap.get(prodName) + oppforecast.gmod__Amount__c);
            } else {
                quarterMap.put(prodName, oppforecast.gmod__Quantity__c);
                amountMap.put(prodName, oppforecast.gmod__Amount__c);

        }

       }     
            if ((monthText == 'Apr' || monthText == 'May' || monthText == 'June')&&(year==previousyear  )){
                quarterMap = Quarter2;
                amountMap = Amount2;
                if (quarterMap.containskey(prodName)) {
                quarterMap.put(prodName, quarterMap.get(prodName) + oppforecast.gmod__Quantity__c);
                amountMap.put(prodName, amountMap.get(prodName) + oppforecast.gmod__Amount__c);
            } else {
                quarterMap.put(prodName, oppforecast.gmod__Quantity__c);
                amountMap.put(prodName, oppforecast.gmod__Amount__c);

                }
                }
            if ((monthText == 'Jul' || monthText == 'Aug' || monthText == 'Sept')&&(year==previousyear)){
                quarterMap = Quarter3;
                amountMap = Amount3;
                if (quarterMap.containskey(prodName)) {
                quarterMap.put(prodName, quarterMap.get(prodName) + oppforecast.gmod__Quantity__c);
                amountMap.put(prodName, amountMap.get(prodName) + oppforecast.gmod__Amount__c);
            } else {
                quarterMap.put(prodName, oppforecast.gmod__Quantity__c);
                amountMap.put(prodName, oppforecast.gmod__Amount__c);
            }
            }
            if ((monthText == 'Oct' || monthText == 'Nov' || monthText == 'Dec')&&(year==previousyear)) {
                quarterMap = Quarter4;
                amountMap = Amount4;
                 if (quarterMap.containskey(prodName)) {
                quarterMap.put(prodName, quarterMap.get(prodName) + oppforecast.gmod__Quantity__c);
                amountMap.put(prodName, amountMap.get(prodName) + oppforecast.gmod__Amount__c);
            } else {
                quarterMap.put(prodName, oppforecast.gmod__Quantity__c);
                amountMap.put(prodName, oppforecast.gmod__Amount__c);


            wrapperclass w = new wrapperclass();
            w.gmod_Opportunity = oppforecast.gmod__Opportunity__r.Name;
            w.gmod_Product = prodName;
            w.gmod_Quantity = oppforecast.gmod__Quantity__c;
            w.gmod_Price = oppforecast.gmod__Price__c;
            w.Name = oppforecast.Name;
            w.gmod_Quarter = oppforecast.gmod__Quarter__c;
            w.gmod_Month = oppforecast.gmod__Month__c;
            w.gmod_Amount = oppforecast.gmod__Amount__c;
            w.Actual_Price = oppforecast.Actual_Price__c;
            w.gmod_Year = oppforecast.gmod__Year__c;
            w.gmod_date = oppforecast.gmod__date__c;
            w.gmod_Month_Text = monthText;
            w.Forecast_Date = oppforecast.Forecast_Date__c;
            disp_list.add(w);
}

}            

            for (Quote qt: q) {
            System.debug('Quote Size ++ '+q.size());
             System.debug('opp forcast ++ ' +opflist.size());
                for (integer i = 0; i < opflist.size(); i++) {


                    //Instantiating the wrapper SObject     
                  /* wrapperclass w = new wrapperclass();
                    //Assigning the wrapper variables from the SObject Fields in the database.     
                    w.gmod_Opportunity = opflist[i].gmod__Opportunity__r.Name;
                    w.gmod_Product = opflist[i].gmod__Product__r.Name;
                    w.gmod_Quantity = opflist[i].gmod__Quantity__c;
                    w.gmod_Price = opflist[i].gmod__Price__c;
                    w.Name = opflist[i].Name;
                    w.gmod_Quarter = opflist[i].gmod__Quarter__c;
                    w.gmod_Month = opflist[i].gmod__Month__c;
                    w.gmod_Amount = opflist[i].gmod__Amount__c;
                    w.Actual_Price = opflist[i].Actual_Price__c;
                    w.gmod_Year = opflist[i].gmod__Year__c;
                    w.gmod_date = opflist[i].gmod__date__c;
                    w.gmod_Month_Text = opflist[i].gmod__Month_Text__c;
                    w.Forecast_Date = opflist[i].Forecast_Date__c;*/

                }//End of For loop int
            }//End of For loop Quote
        }//End of For loop gmod

  }//End of disp


    //Declare a wrapper class      
       public class Wrapperclass  {
        //custom wrapper datatype      
        Public string Name{get;set;}  
        Public string AccountType{get;set;}  
        Public date todaysDate{get;set;}  
        Public date Expected_Order_Date{get;set;}
        Public string Probability{get;set;}  
        Public string Internal_Comment{get;set;}  
        Public string External_Comment{get;set;}      
        Public string Segment{get;set;}  
        Public string Application{get;set;}  
        Public string Persona{get;set;}  
        Public string Geogrpahy{get;set;}      
        Public string PartNumbers{get;set;}  
        Public Decimal  Price{get;set;}  
        Public Decimal End_Customer_Price{get;set;}  
        Public Decimal Quantity {get;set;}  
        Public Decimal Total{get;set;}      
        Public string RFQ_justification{get;set;}  
        Public string Main_Customer_of_Account{get;set;}  
        Public string Bridgelux_competition_at_account{get;set;}
        Public string Geographic_regions_serviced{get;set;}  
        Public string Annual_lighting_revenue{get;set;}  
        Public string Annual_LED_revenue_or_percent{get;set;}  
        Public string Annual_purchases_of_LED_light_sources{get;set;}
        Public string Percent_of_LED_purchases_that_are_COB{get;set;}  
        Public string Other_information{get;set;}      
        Public string Product_Series{get;set;}  
        Public string Volume{get;set;} 
        Public string Date_Price_is_Valid{get;set;}     
        Public string gmod_Opportunity{get;set;}
        Public string gmod_Product{get;set;}
        Public Decimal gmod_Quantity{get;set;}
        Public Decimal gmod_Price{get;set;}
        Public Decimal gmod_Quarter{get;set;}
        Public Decimal gmod_Month{get;set;}
        Public Decimal gmod_Amount{get;set;}
        Public Decimal Actual_Price{get;set;}
        Public Decimal  gmod_Year{get;set;}
        Public Date gmod_date{get;set;}
        Public string gmod_Month_Text{get;set;}
        Public Date  Forecast_Date{get;set;}
    }
  } //End of Class

VF CODE :

<apex:page standardController="Quote" 
        applyHtmlTag="false"    showheader="false" applyBodyTag="false" extensions="QuoteContentController" renderAs="pdf">


  <div class="title"> <center> <h2>RFQ Information  </h2> </center> </div>
  <!-- <b>General Information  </b> -->
    <table cellspacing="0" cellpadding="0" width="100%" border="0" >
        <tr>

            <th bgcolor="Silver">General</th>
            <th bgcolor="Silver">Information:</th>
            <th bgcolor="Silver">Justification and Account </th>
            <th bgcolor="Silver">Information:</th>

         </tr>
       <!-- </table>
    <table  border="0" cellpadding="0" cellspacing="0" width="100%">-->
       <!-- <tr width="10%">
        <td style="border-width: 0px; border-color:Black;border-style:solid;background-color:#FFFFFF;" align="left" width="10%">
        <f style="color:Black; font-size:12px; font-family:Verdana;">
            <td class="labelCol" >QuoteNumber:</td>
            <td class="data2Col"><apex:outputText value="{!Quote.QuoteNumber}"/></td>
             </f>
        </td>-->
            <tr>
            <td ><f style="color:Black; font-size:12px; font-family:Verdana;">QuoteNumber:</f></td>
            <td class="header-data"><apex:outputText value="{!Quote.QuoteNumber}"/></td>
            <td ><f style="color:Black; font-size:12px; font-family:Verdana;">RFQ Justification:</f></td>
            <td class="header-data"><apex:outputField value="{!Quote.Account.Name}"/></td>
            </tr> 

            <tr>
            <td> <f style="color:Black; font-size:12px; font-family:Verdana;">CustomerName: </f></td>
            <td class="header-data"><apex:outputField value="{!Quote.Name}"/></td>
            <td ><f style="color:Black; font-size:12px; font-family:Verdana;">Main Customers of Account:</f></td>
            <td class="header-data"><apex:outputField value="{!Quote.Account.Main_Customers_of_Account__c}"/></td>
            </tr>

            <tr>
            <td> <f style="color:Black; font-size:12px; font-family:Verdana;">Account Type:</f></td>
            <td class="header-data"><apex:outputField value="{!Quote.Account.Recordtype.Name}"/></td>
            <td ><f style="color:Black; font-size:12px; font-family:Verdana;">Bridgelux Competition at Account:</f></td>
            <td class="header-data"><apex:outputField value="{!Quote.Account.Bridgelux_Competition_at_Account__c}"/></td>
            </tr>

            <tr>
            <td> <f style="color:Black; font-size:12px; font-family:Verdana;">Date:</f></td>
            <td class="header-data"><apex:outputField value="{!Quote.Effective_Date__c}"/></td>
            <td ><f style="color:Black; font-size:12px; font-family:Verdana;">Geographic regions serviced:</f></td>
            <td class="header-data"><apex:outputField value="{!Quote.Account.Servicing_Region__c}"/></td>
            </tr>

            <tr>
            <td ><f style="color:Black; font-size:12px; font-family:Verdana;">Expected Order Date:</f></td>
            <td class="header-data"><apex:outputField value="{!Quote.Effective_Date__c}"/></td>
            <td ><f style="color:Black; font-size:12px; font-family:Verdana;">Annual lighting revenue:</f></td>
            <td class="header-data"><apex:outputField value="{!Quote.Account.Annual_LED_Revenue__c}"/></td>
            </tr>

            <tr>
            <td ><f style="color:Black; font-size:12px; font-family:Verdana;">Internal Comments:</f></td>
            <td class="header-data"><apex:outputField value="{!Quote.Description}"/></td>
            <td ><f style="color:Black; font-size:12px; font-family:Verdana;">Annual LED revenue or percent:</f></td>
            <td class="header-data"><apex:outputField value="{!Quote.Account.Annual_LED_Revenue__c}"/></td>
            </tr>

            <tr>
            <td ><f style="color:Black; font-size:12px; font-family:Verdana;">External Comments: </f></td>
            <td class="header-data"><apex:outputField value="{!Quote.Comments__c}"/></td>
            <td ><f style="color:Black; font-size:12px; font-family:Verdana;">Annual Purchases of LED Sources (SAM):</f></td>
            <td class="header-data"><apex:outputField value="{!Quote.Account.Annual_Purchases_of_LED_Sources_SAM__c}"/></td>
            </tr>

            <tr>
            <td ><f style="color:Black; font-size:12px; font-family:Verdana;">Probability(%):</f></td>
            <td class="header-data"><apex:outputField value="{!Quote.Opportunity.Probability}"/></td>
            <td ><f style="color:Black; font-size:12px; font-family:Verdana;">Percent of LED purchases that are COB:</f></td>
            <td class="header-data"><apex:outputField value="{!Quote.Account.Percent_of_LED_purchases_that_are_COB__c}"/></td>
            </tr>

            <tr>
            <td ><f style="color:Black; font-size:12px; font-family:Verdana;">Segment:</f></td>
            <td class="header-data"><apex:outputField value="{!Quote.Opportunity.AccSegment__c}"/></td>
            <td ><f style="color:Black; font-size:12px; font-family:Verdana;">Other Info:</f></td>
            <td class="header-data"><apex:outputField value="{!Quote.Account.Percent_of_LED_purchases_that_are_COB__c}"/></td>
            </tr>

            <tr>
            <td ><f style="color:Black; font-size:12px; font-family:Verdana;">Application:</f></td>
            <td class="header-data"><apex:outputField value="{!Quote.Opportunity.AccApplication__c}"/></td>
            </tr>

            <tr>
            <td ><f style="color:Black; font-size:12px; font-family:Verdana;">Persona:</f></td>
            <td class="header-data"><apex:outputField value="{!Quote.Opportunity.Persona__c}"/></td>
            </tr>

            <tr>
            <td ><f style="color:Black; font-size:12px; font-family:Verdana;">Geography:</f></td>
            <td class="header-data"><apex:outputField value="{!Quote.Opportunity.Region__c}"/></td>
            </tr>

           <!-- <tr>
            <td ><f style="color:Black; font-size:12px; font-family:Verdana;">Opportunity RecordType:</f></td>
            <td class="header-data"><apex:outputField value="{!Quote.Opportunity.RecordType.Name}"/></td>
            </tr> -->

          </table>


   <h3>QuotelineItems Details</h3>
    <table class="bordered">
        <thead> 
                <tr>
                <!--<td bgcolor="Silver" class="header-table-heading">Part</td>-->
                <td class="header-table-heading" bgcolor="#C0C0C0">PartNumbers</td>
                <td class="header-table-heading" bgcolor="#C0C0C0">Price</td>
                <td class="header-table-heading" bgcolor="#C0C0C0">EndCustomerPrice</td>
                <td class="header-table-heading" bgcolor="#C0C0C0">Quantity</td>
                <td class="header-table-heading" bgcolor="#C0C0C0">Total</td>
            </tr>
          </thead> 
        <tbody>
            <apex:repeat value="{!Quote.QuotelineItems}" var="qli">

            <tr>
                <td class="header-table-data" ><apex:outputText value="{!qli.Product2.Name}"/></td>
                <td class="header-table-data" ><apex:outputText value="{!qli.Unitprice}"/></td>
                <td class="header-table-data"><apex:outputField value="{!qli.End_Customer_Price__c}"/></td>
                <td class="header-table-data"><apex:outputField value="{!qli.Quantity}"/></td>
                <td class="header-table-data"><apex:outputField value="{!qli.TotalPrice}"/></td>
            </tr>
            </apex:repeat>
        </tbody>
    </table> 




     <h3>Competitive Data</h3>
    <table class="bordered">
        <thead>
            <tr>
                <td class="header-table-heading" bgcolor="#C0C0C0">Company</td>
                <td class="header-table-heading" bgcolor="#C0C0C0">Product Series</td>
                <td class="header-table-heading" bgcolor="#C0C0C0">Part Numbers</td>
                <td class="header-table-heading" bgcolor="#C0C0C0">Price</td>
                <td class="header-table-heading" bgcolor="#C0C0C0">volume</td>
                <td class="header-table-heading" bgcolor="#C0C0C0">Date Price is Valid</td>
            </tr>
        </thead>
        <tbody>
            <apex:repeat value="{!Quote.Competitor_s__r}" var="com">
            <tr>
                <td class="header-table-data"><apex:outputText value="{!com.Name}"/></td>
                <td class="header-table-data"><apex:outputText value="{!com.Product_Series__c}"/></td>
                <td class="header-table-data"><apex:outputField value="{!com.Part_Number__c }"/></td>
                <td class="header-table-data"><apex:outputField value="{!com.Price_Offered__c}"/></td>
                <td class="header-table-data"><apex:outputField value="{!com.Volume__c}"/></td>
                <td class="header-table-data"><apex:outputField value="{!com.Date_Price_is_Valid__c}"/></td>
            </tr>
            </apex:repeat>
        </tbody>
    </table> 

<apex:variable value="{!0.00}" var="total1"/>
<apex:variable value="{!0.00}" var="total2"/>
<apex:variable value="{!0.00}" var="total3"/>
<apex:variable value="{!0.00}" var="total4"/>
<apex:variable value="{!0.00}" var="total5"/>
<apex:variable value="{!0.00}" var="total6"/>
<apex:variable value="{!0.00}" var="total7"/>
<apex:variable value="{!0.00}" var="total8"/>

<h3>OpportunityForecast Details</h3>

<table class="bordered">
        <thead>
            <tr>
                <td class="header-table-heading" bgcolor="#C0C0C0" colspan="3"  ></td>
                <td class="header-table-heading" bgcolor="#C0C0C0" colspan="6" >FORECAST DATE</td>
               </tr>
               <tr>              
                <td class="header-table-heading" bgcolor="#C0C0C0">Opportunity Name</td>
                <td class="header-table-heading" bgcolor="#C0C0C0">PartNumbers</td>
                <td class="header-table-heading" bgcolor="#C0C0C0">Year</td>
                <td class="header-table-heading" bgcolor="#C0C0C0"></td>
                <td class="header-table-heading" bgcolor="#C0C0C0">Q1 2014 </td>
                <td class="header-table-heading" bgcolor="#C0C0C0">Q2 2014 </td>
                <td class="header-table-heading" bgcolor="#C0C0C0">Q3 2014 </td>
                <td class="header-table-heading" bgcolor="#C0C0C0">Q4 2014 </td>

                <td rowspan="0" class="header-table-heading">Grand<br/>Total </td> 
              </tr>
         </thead>
        <tbody>
           <apex:repeat value="{!disp_list}" var="opf">
            <tr>

                <td class="header-table-data"><apex:outputText value="{!opf.gmod_Opportunity}"/></td>
                <td class="header-table-data"><apex:outputText value="{!opf.gmod_Product}"/></td>
                <td class="header-table-data"><apex:outputText value="{!opf.gmod_Year }"/></td>
                <td class="header-table-data" >Forecast Qty<br/>ForecastAmt<br/></td>
                <td class="header-table-data"><apex:outputText value="{!Quarter1[opf.gmod_Product]}"/>,<br/>$<apex:outputText value="{!Amount1[opf.gmod_Product]}"/>,<br/></td>
                <td class="header-table-data"><apex:outputText value="{!Quarter2[opf.gmod_Product]}"/>,<br/>$<apex:outputText value="{!Amount2[opf.gmod_Product]}"/>,<br/></td>
                <td class="header-table-data"><apex:outputText value="{!Quarter3[opf.gmod_Product]}"/>,<br/>$<apex:outputText value="{!Amount3[opf.gmod_Product]}"/>,<br/></td>
                <td class="header-table-data"><apex:outputText value="{!Quarter4[opf.gmod_Product]}"/>,<br/>$<apex:outputText value="{!Amount4[opf.gmod_Product]}"/>,<br/></td>

                <td class="header-table-data"><apex:outputText value="{!Quarter1[opf.gmod_Product]+Quarter2[opf.gmod_Product]+Quarter3[opf.gmod_Product]+Quarter4[opf.gmod_Product]}"/>,<br/>$<apex:outputText value="{!Amount1[opf.gmod_Product]+Amount2[opf.gmod_Product]+Amount3[opf.gmod_Product]+Amount4[opf.gmod_Product]}"/>,<br/></td>

                 <!--<apex:variable var="total1" value="{!total + previousyear[opf.gmod_Year]}" />-->

                <apex:variable var="total1" value="{!total1 + Quarter1[opf.gmod_Product]}" />
                <apex:variable var="total5" value="{!total5 + Amount1[opf.gmod_Product]}" />

                <apex:variable var="total2" value="{!total2 + Quarter2[opf.gmod_Product]}" />
                <apex:variable var="total6" value="{!total6 + Amount2[opf.gmod_Product]}" />

                <apex:variable var="total3" value="{!total3 + Quarter3[opf.gmod_Product]}" />
                <apex:variable var="total7" value="{!total7 + Amount3[opf.gmod_Product]}" />

                <apex:variable var="total4" value="{!total4 + Quarter4[opf.gmod_Product]}" />
                <apex:variable var="total8" value="{!total8 + Amount4[opf.gmod_Product]}" />
             </tr>
           </apex:repeat> 
       </tbody>

            <tfoot>
                   <tr class="foot">
                         <tr>

                     <td colspan="3" style="text-align:left" align="right" class="header-table-data" >SubTotal :</td>
                     <td colspan="0"  class="header-table-data"  >Forecast Qty<br/>ForecastAmt<br/> </td>

                     <td colspan="1"  class="header-table-data">{!total1}<br/>${!total5},<br/></td>
                     <td colspan="1"  class="header-table-data">{!total2}<br/>${!total6},<br/></td>
                     <td colspan="1"  class="header-table-data">{!total3}<br/>${!total7},<br/></td>
                     <td colspan="1"  class="header-table-data">{!total4}<br/>${!total8},<br/></td>
                     <td colspan="1"  class="header-table-data">{!total1+total2+total3+total4}<br/>${!total5+total6+total7+total8},<br/></td>

                      </tr>    

                      <tr>

                       <td colspan="3" style="text-align:left"  align="right" class="header-table-heading">GrandTotal</td>
                       <td colspan="0"  class="header-table-heading">Forecast Qty<br/>ForecastAmt<br/> </td>
                       <td colspan="1"  class="header-table-heading">{!total1}<br/>${!total5},<br/></td>
                       <td colspan="1"  class="header-table-heading">{!total2}<br/>${!total6},<br/></td>
                       <td colspan="1"  class="header-table-heading">{!total3}<br/>${!total7},<br/></td>
                       <td colspan="1"  class="header-table-heading">{!total4}<br/>${!total8},<br/></td>
                       <td colspan="1"  class="header-table-heading">{!total1+total2+total3+total4}<br/>${!total5+total6+total7+total8},<br/></td>

                       </tr> 
                       </tr>
               </tfoot> 
             </table> 
</apex:page>

enter image description here Any help very much appreciated

25
  • 1
    Are you sure there is data for 2015? If you use a access a map in visualforce, the key has to be there or else you get this kind of error, it wont fail gracefully.
    – CyberJus
    Commented Apr 5, 2015 at 21:19
  • @CyberJus:I do have the data for 2015 , in quarter1 for the month of march I do have the data given.
    – nikkey
    Commented Apr 6, 2015 at 8:29
  • @CyberJus:I have updated the code.Any help very much appreciated.
    – nikkey
    Commented Apr 6, 2015 at 11:11
  • Please add your VF code as well.
    – CyberJus
    Commented Apr 6, 2015 at 17:25
  • @ CyberJus:I have update the VF code.
    – nikkey
    Commented Apr 6, 2015 at 17:45

2 Answers 2

1

In your class

    Quarter1 = new Map < String, Decimal > ();
    Quarter2 = new Map < String, Decimal > ();
    Quarter3 = new Map < String, Decimal > ();
    Quarter4 = new Map < String, Decimal > ();

Quarter1, Quarter2, Quarter3, Quarter4 maps are always new( empty) maps. You are not adding any key/value into the map but in your visual force page you are trying to get the value for all the maps using the key (prodname) by

              <td class="header-table-data"><apex:outputText value="{!Quarter1[opf.gmod_Product]}"/>,<br/>$<apex:outputText value="{!Amount1[opf.gmod_Product]}"/>,<br/></td>
                <td class="header-table-data"><apex:outputText value="{!Quarter2[opf.gmod_Product]}"/>,<br/>$<apex:outputText value="{!Amount2[opf.gmod_Product]}"/>,<br/></td>
                <td class="header-table-data"><apex:outputText value="{!Quarter3[opf.gmod_Product]}"/>,<br/>$<apex:outputText value="{!Amount3[opf.gmod_Product]}"/>,<br/></td>
                <td class="header-table-data"><apex:outputText value="{!Quarter4[opf.gmod_Product]}"/>,<br/>$<apex:outputText value="{!Amount4[opf.gmod_Product]}"/>,<br/></td>

To simplify

The quarter maps look like this

String(key)      Decimal(Value)

(empty)          (empty)

You are instructing your vf page to go and fect a key (BXRC-25E4000-F-04) for which the controller says "Key not found in the map"

1
  • :Thanks for your reply.Apart from map do we have any alternate to get the value.
    – nikkey
    Commented Apr 6, 2015 at 18:49
0

should the "E" be lower case. BXRC-25E4000-F-04.

or

you are trying the leave the product name blank for presentation purposes but you are also using the product name as the key in your map. Add the product name as a field in the map values for presentation and do not blank the map key.

1
  • :Thanks for your reply.I have updated the complete code.Any help very much appreciated.
    – nikkey
    Commented Apr 6, 2015 at 11:12

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .