• SIB Admin
  • NEWBIE
  • 0 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 12
    Questions
  • 16
    Replies
Hi,

I have a custom object.I have two fields, SIB Sales Rep(Contact lookup field) and stage(picklist).I want to create an automated activity for the person listed in the "Primary Sales Rep" field when the stage picklist has a value "Closed/ Won".I know this can be done by writing apex trigger.However, I am new to apex code.If somebody could help me with the code, that would be great.

Thanks
Hi,

We have Activities(Related List) under Account and we have  a child object called "LED Lighting Opportunity" and activities (Related List) under "LED Lighting Opportunity".I want to write a webservice method that creates activities under "LED Lighting Opportunity" rather than activities under account level.Here is the existing code.How do I update it to refer activities under LED Lighting Opportunity?

//Webservice for quickly logging a voicemail for sales reps.
  ////////////////////////////////////////////////////////////
  webservice static void logACall(ID contactId, ID userId, Integer days, String callResult){
    
    //Get a list of the contact itself, the account of the contact, and all open tasks on the contact.
    List<Contact> contact = [SELECT Id, AccountId FROM Contact WHERE Id = :contactId];
    List<Account> account = [SELECT Id FROM Account WHERE Id = :contact[0].AccountId];
    List<Task> openTask = [SELECT Id, OwnerId, Who__c, Type, Subject, ActivityDate, Priority, Status, Description, WhatId, WhoId From Task Where WhoId = :contactId AND Status = 'Not Started'];
    

    //If there is at least one open task...
    if (openTask.size() > 0) {
      //Create an exact copy of the task that will be postponed (days) number of days later.
      Task followUpTask = openTask[0].clone(false, false, false, false);
      followUpTask.ActivityDate = followUpTaskDate(days);
      
      //Close out the open task and set the subject to 'Call No Answer Left VM'.
      openTask[0].Subject = callResult;
      openTask[0].Status = 'Completed';
      
      insert followUpTask;
      update openTask[0];
      
    }
    
    //There is no open task so we need to create a followUpTask from scratch and then clone a completedTask.
    else {
      Task followUpTask = new Task(OwnerId = userId, Type = '@Call', Subject = '@Call', ActivityDate = followUpTaskDate(days), Priority = 'Normal', Status = 'Not Started', WhoId = contact[0].Id, WhatId = account[0].Id);
      Task completedTask = followUpTask.clone(false, false, false, false);
      
      //Closed out the completedTask and set the subject to 'Call No Answer Left VM'.
      completedTask.Subject = callResult;
      completedTask.ActivityDate = system.today();
      completedTask.Status = 'Completed';
      
      insert followUpTask;
      insert completedTask;
    }
  }
  
  //Private class method for calculating the follow task date in business days.
  private static Date followUpTaskDate(Integer d){
    //Set the date of the follow task to (days) number of days later.
    //Get a date and a datetime for (days) number of days later.
    Date taskDate = system.today().addDays(d);
    datetime dt = system.today().addDays(d + 1);

    //If the date falls on a Saturday, add 2 days to the date.
    if (dt.format('EEEE') == 'Saturday'){
      taskDate = taskDate.addDays(2);
    }
    //If the date falls on a Sunday, add 1 day to the date.
    else if (dt.format('EEEE') == 'Sunday'){
      taskDate = taskDate.addDays(1);
    }
    return taskDate;
  }
}
Hi,

I have the following ASRinitialization trigger class.It says 0% code coverage.Can somebody help me out in identifying what am I missing?


// This trigger was created to initialize the ASR with all the relevant ASR Attributes that are laid out in the definition record for that category type.
// Test Class: ASRInitializationTest.cls

// Modified 3/8/2017 - ASRMISC-5 - to handle generic fields

trigger ASRInitialization on ASR__c (after insert) {

    for(ASR__c asr : Trigger.new){
        //Get a list of all the attributes relevant for this ASRs
        ASR__c asrWithAuditType = [SELECT Id, Audit__r.Audit_Type__c FROM ASR__c WHERE Id = :asr.Id];
        String auditType = asrWithAuditType.Audit__r.Audit_Type__c;
        System.debug(auditType);
        Audit_Definition__c auditDefinition = [SELECT Id, Name, Audit_Type__c,
                                                (SELECT Section__c, Section_Label__c, Object_Type__c, Field__c, Label__c, Order__c, Hidden__c, Column_Width__c
                                                 FROM ASR_Attributes__r)
                                               FROM Audit_Definition__c
                                               WHERE Audit_Type__c = :auditType];

        //Copy the list and attach it to the ASR
        List<ASR_Attribute__c> attrs = new List<ASR_Attribute__c>();
        for(ASR_Attribute__c attr : auditDefinition.ASR_Attributes__r){
            attr.Id = null;
            attr.Audit_Definition__c = null;
            attr.ASR__c = asr.Id;
            attrs.add(attr);
        }
        insert attrs;


        // ASRMISC-5 - is the ASR marked as having generic fields? If so, we need 15 above-and-beyond ASR Attribute records
        if (asr.Generic_Fields_in_Use__c == true) {
            ASR_Attribute__c attrC1 = new ASR_Attribute__c();
            attrC1.Id = null;
            attrC1.Audit_Definition__c = null;
            attrC1.ASR__c = asr.Id;
            attrC1.Section__c = 'Current Spend';
            attrC1.Section_Label__c = 'Current Spend';
            attrC1.Object_Type__c = 'Vendor_Cost__c';
            attrC1.Field__c = '';
            attrC1.Hidden__c = false;
            attrC1.Label__c = asr.Initial_Generic_Field_1_Title__c;
            attrC1.Order__c = 1.1;
            insert attrC1;

            ASR_Attribute__c attrC2 = new ASR_Attribute__c();
            attrC2.Id = null;
            attrC2.Audit_Definition__c = null;
            attrC2.ASR__c = asr.Id;
            attrC2.Section__c = 'Current Spend';
            attrC2.Section_Label__c = 'Current Spend';
            attrC2.Object_Type__c = 'Vendor_Cost__c';
            attrC2.Field__c = '';
            attrC2.Hidden__c = false;
            attrC2.Label__c = asr.Initial_Generic_Field_2_Title__c;
            attrC2.Order__c = 5.1;
            insert attrC2;

            ASR_Attribute__c attrC3 = new ASR_Attribute__c();
            attrC3.Id = null;
            attrC3.Audit_Definition__c = null;
            attrC3.ASR__c = asr.Id;
            attrC3.Section__c = 'Current Spend';
            attrC3.Section_Label__c = 'Current Spend';
            attrC3.Object_Type__c = 'Vendor_Cost__c';
            attrC3.Field__c = '';
            attrC3.Hidden__c = false;
            attrC3.Label__c = asr.Initial_Generic_Field_3_Title__c;
            attrC3.Order__c = 6.1;
            insert attrC3;

            //////////

            ASR_Attribute__c attrBE1 = new ASR_Attribute__c();
            attrBE1.Id = null;
            attrBE1.Audit_Definition__c = null;
            attrBE1.ASR__c = asr.Id;
            attrBE1.Section__c = 'Billing Errors';
            attrBE1.Section_Label__c = 'Achieved Spend - Billing Errors';
            attrBE1.Object_Type__c = 'Vendor_Cost__c';
            attrBE1.Field__c = '';
            attrBE1.Hidden__c = false;
            attrBE1.Label__c = asr.Initial_Generic_Field_1_Title__c;
            attrBE1.Order__c = 1.1;
            insert attrBE1;

            ASR_Attribute__c attrBE2 = new ASR_Attribute__c();
            attrBE2.Id = null;
            attrBE2.Audit_Definition__c = null;
            attrBE2.ASR__c = asr.Id;
            attrBE2.Section__c = 'Billing Errors';
            attrBE2.Section_Label__c = 'Achieved Spend - Billing Errors';
            attrBE2.Object_Type__c = 'Vendor_Cost__c';
            attrBE2.Field__c = '';
            attrBE2.Hidden__c = false;
            attrBE2.Label__c = asr.Initial_Generic_Field_2_Title__c;
            attrBE2.Order__c = 5.1;
            insert attrBE2;

            ASR_Attribute__c attrBE3 = new ASR_Attribute__c();
            attrBE3.Id = null;
            attrBE3.Audit_Definition__c = null;
            attrBE3.ASR__c = asr.Id;
            attrBE3.Section__c = 'Billing Errors';
            attrBE3.Section_Label__c = 'Achieved Spend - Billing Errors';
            attrBE3.Object_Type__c = 'Vendor_Cost__c';
            attrBE3.Field__c = '';
            attrBE3.Hidden__c = false;
            attrBE3.Label__c = asr.Initial_Generic_Field_3_Title__c;
            attrBE3.Order__c = 6.1;
            insert attrBE3;

            //////////

            ASR_Attribute__c attrRR1 = new ASR_Attribute__c();
            attrRR1.Id = null;
            attrRR1.Audit_Definition__c = null;
            attrRR1.ASR__c = asr.Id;
            attrRR1.Section__c = 'Rate Reductions';
            attrRR1.Section_Label__c = 'Achieved Spend - Rate Reductions';
            attrRR1.Object_Type__c = 'Vendor_Cost__c';
            attrRR1.Field__c = '';
            attrRR1.Hidden__c = false;
            attrRR1.Label__c = asr.Initial_Generic_Field_1_Title__c;
            attrRR1.Order__c = 1.1;
            insert attrRR1;

            ASR_Attribute__c attrRR2 = new ASR_Attribute__c();
            attrRR2.Id = null;
            attrRR2.Audit_Definition__c = null;
            attrRR2.ASR__c = asr.Id;
            attrRR2.Section__c = 'Rate Reductions';
            attrRR2.Section_Label__c = 'Achieved Spend - Rate Reductions';
            attrRR2.Object_Type__c = 'Vendor_Cost__c';
            attrRR2.Field__c = '';
            attrRR2.Hidden__c = false;
            attrRR2.Label__c = asr.Initial_Generic_Field_2_Title__c;
            attrRR2.Order__c = 5.1;
            insert attrRR2;

            ASR_Attribute__c attrRR3 = new ASR_Attribute__c();
            attrRR3.Id = null;
            attrRR3.Audit_Definition__c = null;
            attrRR3.ASR__c = asr.Id;
            attrRR3.Section__c = 'Rate Reductions';
            attrRR3.Section_Label__c = 'Achieved Spend - Rate Reductions';
            attrRR3.Object_Type__c = 'Vendor_Cost__c';
            attrRR3.Field__c = '';
            attrRR3.Hidden__c = false;
            attrRR3.Label__c = asr.Initial_Generic_Field_3_Title__c;
            attrRR3.Order__c = 6.1;
            insert attrRR3;

            //////////

            ASR_Attribute__c attrVS1 = new ASR_Attribute__c();
            attrVS1.Id = null;
            attrVS1.Audit_Definition__c = null;
            attrVS1.ASR__c = asr.Id;
            attrVS1.Section__c = 'Vendor Switch';
            attrVS1.Section_Label__c = 'Achieved Spend - Vendor Switch';
            attrVS1.Object_Type__c = 'Vendor_Cost__c';
            attrVS1.Field__c = '';
            attrVS1.Hidden__c = false;
            attrVS1.Label__c = asr.Initial_Generic_Field_1_Title__c;
            attrVS1.Order__c = 1.1;
            insert attrVS1;

            ASR_Attribute__c attrVS2 = new ASR_Attribute__c();
            attrVS2.Id = null;
            attrVS2.Audit_Definition__c = null;
            attrVS2.ASR__c = asr.Id;
            attrVS2.Section__c = 'Vendor Switch';
            attrVS2.Section_Label__c = 'Achieved Spend - Vendor Switch';
            attrVS2.Object_Type__c = 'Vendor_Cost__c';
            attrVS2.Field__c = '';
            attrVS2.Hidden__c = false;
            attrVS2.Label__c = asr.Initial_Generic_Field_2_Title__c;
            attrVS2.Order__c = 5.1;
            insert attrVS2;

            ASR_Attribute__c attrVS3 = new ASR_Attribute__c();
            attrVS3.Id = null;
            attrVS3.Audit_Definition__c = null;
            attrVS3.ASR__c = asr.Id;
            attrVS3.Section__c = 'Vendor Switch';
            attrVS3.Section_Label__c = 'Achieved Spend - Vendor Switch';
            attrVS3.Object_Type__c = 'Vendor_Cost__c';
            attrVS3.Field__c = '';
            attrVS3.Hidden__c = false;
            attrVS3.Label__c = asr.Initial_Generic_Field_3_Title__c;
            attrVS3.Order__c = 6.1;
            insert attrVS3;

            //////////

            ASR_Attribute__c attrSS1 = new ASR_Attribute__c();
            attrSS1.Id = null;
            attrSS1.Audit_Definition__c = null;
            attrSS1.ASR__c = asr.Id;
            attrSS1.Section__c = 'Service Standardization';
            attrSS1.Section_Label__c = 'Achieved Spend - Service Standardization';
            attrSS1.Object_Type__c = 'Vendor_Cost__c';
            attrSS1.Field__c = '';
            attrSS1.Hidden__c = false;
            attrSS1.Label__c = asr.Initial_Generic_Field_1_Title__c;
            attrSS1.Order__c = 1.1;
            insert attrSS1;

            ASR_Attribute__c attrSS2 = new ASR_Attribute__c();
            attrSS2.Id = null;
            attrSS2.Audit_Definition__c = null;
            attrSS2.ASR__c = asr.Id;
            attrSS2.Section__c = 'Service Standardization';
            attrSS2.Section_Label__c = 'Achieved Spend - Service Standardization';
            attrSS2.Object_Type__c = 'Vendor_Cost__c';
            attrSS2.Field__c = '';
            attrSS2.Hidden__c = false;
            attrSS2.Label__c = asr.Initial_Generic_Field_2_Title__c;
            attrSS2.Order__c = 5.1;
            insert attrSS2;

            ASR_Attribute__c attrSS3 = new ASR_Attribute__c();
            attrSS3.Id = null;
            attrSS3.Audit_Definition__c = null;
            attrSS3.ASR__c = asr.Id;
            attrSS3.Section__c = 'Service Standardization';
            attrSS3.Section_Label__c = 'Achieved Spend - Service Standardization';
            attrSS3.Object_Type__c = 'Vendor_Cost__c';
            attrSS3.Field__c = '';
            attrSS3.Hidden__c = false;
            attrSS3.Label__c = asr.Initial_Generic_Field_3_Title__c;
            attrSS3.Order__c = 6.1;
            insert attrSS3;
        }
    }
}



Following is my test class
/*

Tests the ASRInitialization trigger and asserts that when an ASR is created, it's list of ASR attributes is initialized with the same list
from that audit category's definition.
*/


@isTest
private class ASRInitializationTest {

    //Create test data
    @testSetup static void setupTestData(){
        //Test Audit
        testData.createTestAudit();
        Location_Audits__c testAudit = [SELECT Id, Name, Audit_Type__c FROM Location_Audits__c WHERE Account__r.Name = 'Test Account'];

        //Test Audit Definition
        Audit_Definition__c testDefinition = new Audit_Definition__c(
            Audit_Type__c = testAudit.Audit_Type__c
        );
        insert testDefinition;
        testDefinition = [SELECT Id, Name, Audit_Type__c FROM Audit_Definition__c WHERE Audit_Type__c = :testAudit.Audit_Type__c];

        //Test ASR Attribute
        ASR_Attribute__c attr = new ASR_Attribute__c(
            Audit_Definition__c = testDefinition.Id,
            Section__c = 'Location Information',
            Section_Label__c = 'My Section Label',
            Object_Type__c = 'My_Object__c',
            Field__c = 'My_Field__c',
            Label__c = 'My_Label__c',
            Hidden__c = false,
            Order__c = 1
        );
        insert attr;
    }
    
    @isTest static void testASRCreate() {
        //Create a new ASR and relate it to the test audit
        Location_Audits__c testAudit = [SELECT Id, Name, Audit_Type__c FROM Location_Audits__c WHERE Account__r.Name = 'Test Account'];
        ASR__c testASR = new ASR__c(
            Audit__c = testAudit.Id,
            ASR_Date__c = System.today(),
            

        );
        
        insert testASR;
    }


    
    
}
Hi,
I am new to Salesforce testing.When I try to push a trigger class it says your code coverage is below 75%.I need to deploy it urgently.I tried running all tests and by going to developer console to check code coverage for each class.
Here is the screenshot
User-added image

I am thinking if I could exclude the classes with miminal coverage from the code coverage so that they do not lower the overall code coverage.I tried that by annotating each class by @isTest but even after that when I tried run all tests and went to develop console I could still see those classes with 0% coverage.
Need a report that indicates how much API each app and each person consumed on monday 9th october that exceeded our API limit.

organization id: 00D80000000aSjb
Hi,

I am trying to create a subsection in opportunity object that has two fields inside it.

1. Escalating Invoice Collection to SIB (checkbox)
2. Invoice Collection Escalation Notes (textbox)

I have written an apex code for that
<apex:page standardController="Opportunity" tabStyle="Opportunity">

<script>
function colorPageBlock(pageblock, color) {
if (pageblock != null) pageblock.firstChild.style.cssText = “background-color: ” + color + “;”;

}
</script>


<apex:form >


    <apex:pageBlock >

        <apex:pageBlockSection id="blueSection" title="Outsource Team Information">
            <apex:inputField value="{!opportunity.Escalating_Invoice_Collection_to_SIB__c}"/><tr></tr>
            <apex:inputField value="{!opportunity.Invoice_Collection_Escalation_Notes__c}"/>
            <script>colorPageBlock(document.getElementById("{!$Component.blueSection}"), "blue");</script>
        </apex:pageBlockSection>

    </apex:pageBlock>

</apex:form>

</apex:page>

But I am unable to edit the fields since this visualforce page does not show up on edit page layout and I can't even edit this on detail page as there is no save option.(Screenshot attached)

User-added image

Also, I want to change the color of "Outsource Team Information" bar from yellow to blue .

User-added image
I have a picklist in salesforce with API name "No_Penalty__c".It has different options e.g 30 Day Out, 45 Day Out, 60 Day Out and then I have an angular page where I have to display the text based on what option user selects from that picklist.So e.g if user selects 30 Day Out, on the angular page I should see "Agreement may be cancelled with no penalty upon 30 days' written notice".Similarly, if user selects 60 Day Out from the picklist then on the Angular page it should display "Agreement may be cancelled with no penalty upon 60 days' written notice".I tried doing the following
                           <div ng-show="No_Penalty__c === '30 Day Out'">
                                <b>Agreement may be cancelled with no penalty upon 30 days' written notice</b>
                           </div>

                            <div ng-show="No_Penalty__c === '60 Day Out'">
                                <b>Agreement may be cancelled with no penalty upon 60 days' written notice</b>
                           </div>

But then it displays both texts on the angular page irrespective of what option is selected in picklist.
I've just finished re-factoring some an old apex controller I wrote a while back. Field testing in the sandbox as far as functionality has shown it works great. Now I'm trying to write the test class for it and I'm having some serious issues. I'm unable to call any of the local variables from within the class. The test class stops running once it reaches line the creation of the aWrappers. It's like it doesn't query for any of the opportunities that are related to the audits. Any help would be greatly appreciated.

Apex Controller
/**
 * Author: Andrew Bettke
 * Date: 12/8/14
 * Last Revision: 10/21/2015
 *
 * The controller handles the 'SIBInvoiceWizard' custom visualforce page. This page will be used by the accounting department to mass create SIB Invoices
 * (along with billing event records) quickly and seamlessly from one page. The page will be accessed from a button on any active client account detail
 * page. From there, the page will dynamically displays editable data tables for each savings item that can billed for that month. After submitting the
 * form with, the controller will analyze the data and created invoice and billing event records accordingly. 
 **
 */
 
public class SIBInvoiceWizard {
	
	//The account for which we will be generating an invoice.
	public Account account {get; set;}
	
	//All audits processing savings for this account.
	
	public List<auditWrapper> aWrappers {get; set;}
	public SIB_Invoice__c invoice {get; set;}
	public Decimal invoiceTotal {get; set;}
	public Decimal inputTotal {get; set;}
	private static set<String> variableSavingsSources = new set<String> {'Generic VoIP Proposal','Plan Optimization',
																		 'Rate Reduction','Service Standardization',
																		 'Vendor Change','Vendor Consolidation'};
	
	//Upon creation, initialize variables and fill lists.
	public SIBInvoiceWizard(){
		
		
		//Instantiate the account by querying the database for the specified ID
		account = [SELECT ID, Name FROM Account Where Id = :ApexPages.currentPage().getParameters().get('accId')];
		
		//Instantiate the Invoice and link it to the Account.
		invoice = new SIB_Invoice__c();
		invoice.Account__c = account.Id;
		invoice.Amount_Paid__c = 0;
		invoiceTotal = 0.00;
		inputTotal = 0.00;
		
		//Grab a list of all relevant audits and their savings to fill the savings and audit wrappers.
		List<Location_Audits__c> auditsWithSavings = [SELECT Id, Name, Stage__c, Audit_Type__c,
									(SELECT ID, Name, Savings_Source__c, Type, Amount, Monthly_Contract_Value__c, CV__c, CV_Total_Billed__c, 
									        CV_Remaining__c, of_Months_Remaining__c, Recurrence_Type__c, Account.Contingency_Fee__c //Sub-query
									 FROM Opportunities__r
									 WHERE (StageName = 'Finalized Savings' OR StageName = 'Engagement Complete') AND CV_Remaining__c > 0)
							 FROM Location_Audits__c 
		                     WHERE Account__r.Id = :account.Id];
		 
		//Create a new list of auditWrappers and fill those auditWrappers with audits from the list above and a list of savingsWrappers.                    
		aWrappers = new List<auditWrapper>();
		for(Location_Audits__c audit : auditsWithSavings){
			List<savingsWrapper> sWrappers = new List<savingsWrapper>();
			for(Opportunity savingsItem : audit.Opportunities__r){
				Savings_Item_Billing_Event__c newSIBE = new Savings_Item_Billing_Event__c();
				newSIBE.Savings_Item__c = savingsItem.Id;
				newSIBE.CV_Billed__c = 0;
				sWrappers.add(new savingsWrapper(savingsItem,newSIBE));
			}
			if(sWrappers.size() > 0){
				aWrappers.add(new auditWrapper(audit,sWrappers));
			}
			
		}
		
	}
	
	public void calculateBillingAllocations(){
		for(auditWrapper a : aWrappers){
			Decimal adjustedCategoryBilling = a.categoryBillingTotal;
			Decimal includedVariableTotal = 0.00;
			//First Loop: Assign fixed billing amounts for one-time savings and fixed monthly savings.
			//While looping, sum the amounts for all included variable savings.
			for(savingsWrapper s : a.savingsWrappers){
				if(s.included == true){
					//We have a one-time or fixed montly savings item.
					if(!variableSavingsSources.contains(s.savingsItem.Savings_Source__c) ){
						s.allocationPercent = 100.00;
						s.sibe.CV_Billed__c = (s.savingsItem.Amount * (s.savingsItem.Account.Contingency_Fee__c/100)).setScale(2,RoundingMode.HALF_UP);
						adjustedCategoryBilling = adjustedCategoryBilling - s.sibe.CV_Billed__c;
					} else{
						includedVariableTotal = includedVariableTotal + s.savingsItem.Amount;
					}
				} else{
					s.allocationPercent = 0.00;
					s.sibe.CV_Billed__c = 0.00;
				}
			}
			
			//Second Loop: Assign allocated billing amounts for variable monthly savings.
			for(savingsWrapper s : a.savingsWrappers){
				if(s.included == true && includedVariableTotal > 0){
					//We have a variable monthly savings item
					if( variableSavingsSources.contains(s.savingsItem.Savings_Source__c) ){
						//Calculate the allocation % for the remaining amount of billing left to allocate.
						s.allocationPercent = ((s.savingsItem.Amount/includedVariableTotal) * 100).setScale(2,RoundingMode.HALF_UP);
						s.sibe.CV_Billed__c = (adjustedCategoryBilling * (s.allocationPercent/100)).setScale(2,RoundingMode.HALF_UP);
					}
				}
			}
		}
		
		invoiceTotal = 0.00;
		inputTotal = 0.00;
		for(auditWrapper a : aWrappers){
			inputTotal = inputTotal + a.categoryBillingTotal;
			for(savingsWrapper s : a.savingsWrappers){
				invoiceTotal = (invoiceTotal + s.sibe.CV_Billed__c).setScale(2,RoundingMode.HALF_UP);
			}
		}
		
		if(invoiceTotal != inputTotal){
			ApexPages.addMessage( 
								 new ApexPages.Message(ApexPages.Severity.ERROR,'The amount recieved from data entry does not match the calculated invoice total. Review your input and recalculate.')
								);
		} else{
			ApexPages.addMessage( 
								 new ApexPages.Message(ApexPages.Severity.CONFIRM,'The input total and calculated invoice total match! You may proceed with submission.')
								);
		}
	}
	
	
	//Called when the form is submitted.
	public PageReference formSubmission(){
		//Insert the created invoice into the database
		try{
			insert invoice;
		
			//Link each billingEvent created back to the newly inserted invoice, then insert the billing events.
			Integer lineItem = 1;
			for(auditWrapper a : aWrappers){
				for(savingsWrapper s : a.savingsWrappers){
					s.sibe.SIB_Invoice__c = invoice.Id;
					if(lineItem < 10){
						s.sibe.Name = invoice.Name + ' - 0' + lineItem;
					} else{
						s.sibe.Name = invoice.Name + ' - ' + lineItem;
					}
					
					if(s.sibe.CV_Billed__c != null || s.sibe.CV_Billed__c == 0){
						insert s.sibe;
						lineItem = lineItem + 1;
					}
				}
			}
			
			//Create a new page reference for the invoice and redirect the user to the newly created invoice.
			PageReference invoiceDetail = new PageReference('/'+invoice.Id);
			invoiceDetail.setRedirect(true);
			return invoiceDetail;
		} catch(DmlException e){
			if( e.getMessage().contains('DUPLICATE_VALUE') ){
				ApexPages.addMessage( 
								 new ApexPages.Message(ApexPages.Severity.ERROR,'Duplicate Invoice ID found. This Invoice # already exists.')
								);
				return ApexPages.currentPage();
			} else{
				ApexPages.addMessage( 
								 new ApexPages.Message(ApexPages.Severity.ERROR,'A generic DML exception has occured. Please contact the system administrator.')
								);
				return ApexPages.currentPage();
			}
			
		} catch(Exception e){
			ApexPages.addMessage( 
								 new ApexPages.Message(ApexPages.Severity.ERROR,'A generic exception error has occured. Please contact the system administrator.')
								);
			return ApexPages.currentPage();
		}
	}
	
	
	class auditWrapper{
		
		public Location_Audits__c audit {get; set;}
		public List<savingsWrapper> savingsWrappers {get; set;}
		public Decimal recurringVariableTotal {get; set;}
		public Decimal categoryTotal {get; set;}
		public Decimal categoryBillingTotal {get; set;}
		
		public auditWrapper(Location_Audits__c audit, List<savingsWrapper> savingsWrappers){
			this.audit = audit;
			this.savingsWrappers = savingsWrappers;
			this.categoryTotal = 0;
			this.categoryBillingTotal = 0.00;
		}
		
	}
	
	class savingsWrapper{
		
		public Opportunity savingsItem {get; set;}
		public Savings_Item_Billing_Event__c sibe {get; set;}
		public Decimal allocationPercent {get; set;}
		public Boolean included {get; set;}
		
		public savingsWrapper(Opportunity savingsItem, Savings_Item_Billing_Event__c sibe){
			this.savingsItem = savingsItem;
			this.sibe = sibe;
		}
		
	}

	
}

Visualforce Page
<apex:page controller="SIBInvoiceWizard" docType="html-5.0">
	
	<apex:includeScript value="/soap/ajax/29.0/connection.js"/>
	<apex:includeScript value="/soap/ajax/29.0/apex.js"/>
	    	
	<style type="text/css">
	
	    
		.col-md {
			width:10%;
		}
		.col-sm {
			width:5%;
		}
		
		.totals td{
	    	font-weight:bold;
	    }
	    
	    .totals .col1{
	    	width:77%;
	    }
	    
	
	</style>   
	    	
	
		<apex:pageMessages />
		<apex:sectionHeader title="SIB Invoice Wizard"/>
			
			<apex:form id="wizardForm">
			
				<apex:PageBlock id="invoiceDetails" title="Invoice Details">
					<table style="table-layout:fixed;width:50%;">
						<tr>
							<td>
								<apex:outputLabel value="Invoice # " style="font-weight:bold"/>
							</td>
							<td>
								<apex:outputLabel value="Invoice Date " style="font-weight:bold"/>
							</td>
							<td>
								<apex:outputLabel value="Amount Paid " style="font-weight:bold"/>
							</td>

						</tr>
						<tr>
							<td>
								<apex:inputField id="invoiceNumber" value="{!invoice.Name}"  required="true"/>
							</td>
							<td>
								<apex:inputField id="invoiceDate" value="{!invoice.Invoice_Date__c}"/>
							</td>
							<td>
								<apex:inputField id="amountPaid" value="{!invoice.Amount_Paid__c}"/>
							</td>
						</tr>
					</table>
					
					
				</apex:PageBlock>
				
				<apex:PageBlock id="savingsForm" onkeyup="totalBillingEvents();">
				
					
						<apex:repeat value="{!aWrappers}" var="a">
	
							<apex:pageBlockSection title="{!a.audit.Name + ' (' + a.audit.Audit_Type__c + ')'}" columns="1">
						
								<apex:outputPanel layout="block" style="width:100%;" id="savingsTables">
								
								<table>
									
									<tr>
										<th class="col-md">Name</th>
										<th class="col-md">Savings Source</th>
										<th class="col-sm">Type</th>
										<th class="col-sm">Recurrence Type</th>
										<th class="col-sm">Allocation Factor</th>
										<th class="col-sm">Monthly Savings</th>
										<th class="col-sm">Monthly CV</th>
										<th class="col-sm">CV Billed</th>
										<th class="col-sm">CV Remaining</th>
										<th class="col-sm">Current Billing</th>
										<th class="col-sm"># of Months Included</th>
										<th class="col-sm">Item Included</th>
									</tr>
									
									<apex:repeat value="{!a.savingsWrappers}" var="s">
									<tr>
										<td class="col-md"><apex:outputLink value="/{!s.savingsItem.Id}">{!s.savingsItem.Name}</apex:outputLink></td>
										<td class="col-md">{!s.savingsItem.Savings_Source__c}</td>
										<td class="col-sm">{!s.savingsItem.Type}</td>
										<td class="col-sm">{!s.savingsItem.Recurrence_Type__c}</td>
										<td class="col-sm">{!s.allocationPercent}%</td>
										<td class="col-sm">${!s.savingsItem.Amount}</td>
										<td class="col-sm">${!s.savingsItem.Monthly_Contract_Value__c}</td>
										<td class="col-sm">${!s.savingsItem.CV_Total_Billed__c}</td>
										<td class="col-sm">${!s.savingsItem.CV_Remaining__c}</td>
										<td class="col-sm">
											<apex:outputText value="{0, number, currency}" style="width:70%;">
												<apex:param value="{!s.sibe.CV_Billed__c}"/>
											</apex:outputText>
										</td>
										<td class="col-sm"><apex:inputField value="{!s.sibe.of_Months_Included__c}" style="width:25%;"/></td>
										<td class="col-sm"><apex:inputCheckbox value="{!s.included}" style="text-align:center;"/></td>
									</tr>
									</apex:repeat>
									
									
									<tr class="totals">
										<td  colspan="9">Total Billed for Audit Category</td>
										<td><apex:inputText value="{!a.categoryBillingTotal}" style="width:70%;"/></td>
									</tr>
									
								</table>
										
								</apex:outputPanel>
	
							</apex:pageBlockSection>
							
						</apex:repeat>
						
					<apex:pageBlockSection columns="1">
					<apex:outputPanel layout="block" style="width:100%;">
						<table class="totals" style="width:100%;margin-top:2%">
							<tr>
								<td class="col1">Invoice Total</td>
								<td><apex:outputText value="{0, number, currency}" style="color:{!IF(invoiceTotal==inputTotal,'green','red')};">
										<apex:param value="{!invoiceTotal}"/>
									</apex:outputText>
								</td>
							</tr>
							<tr class="totals">
								<td class="col1">Billing Input Total</td>
								<td><apex:outputText value="{0, number, currency}">
										<apex:param value="{!inputTotal}"/>
									</apex:outputText>
								</td>
							</tr>
							<tr>
								<td class="col1"></td>
								<td><apex:commandButton value="Calculate" rerender="" action="{!calculateBillingAllocations}"/></td>
							</tr>
							<tr>
								<td class="col1"></td>
								<td><apex:commandButton value="Submit" rerender="" action="{!formSubmission}" disabled="{!(invoiceTotal=0 ||
																														   inputTotal=0 ||
																														   invoiceTotal != inputTotal)
																														}"/>
								</td>
							</tr>
						</table>
					</apex:outputPanel>
					</apex:pageBlockSection>
					
				</apex:PageBlock>
				
			</apex:form>
			
			<script type="text/javascript">
		
				function totalBillingEvents(){
					var itemAmountElements = document.getElementById("{!$Component.wizardForm.savingsForm}").getElementsByTagName("input");
					var total = 0;
		
					for(i = 0; i < itemAmountElements.length; i++){
						var currency = itemAmountElements[i].value;
						var number = Number(currency.replace(/[^0-9\.-]+/g,""));
						total = total + number;
						i = i + 1
					}
					
					document.getElementById("{!$Component.wizardForm.savingsForm.invoiceTotal}").innerHTML = "$"+total.toFixed(2);
				}		
		
			</script>
	
	</apex:page>
Apex Test Class
/**
 *
 */
@isTest
private class SIBInvoiceWizardTest {

    static testMethod void SIBInvoiceWizardMainTest() {
        Account testAccount = new Account(Name = 'Test Account', RecordTypeId = '012C0000000GCJv', Industry = 'Banking',Status__c = 'Active');
        insert testAccount;
        
        Location_Audits__c testAudit = new Location_Audits__c(Account__c = testAccount.Id, Stage__c = 'Audit Complete - Processing Savings', Audit_Type__c = 'CO2', Current_Analyst__c = 'Andrew Bettke');
        insert testAudit;
        
        Opportunity testSavingsItem = new Opportunity(Name = 'testSavings', Account = testAccount, Audit_Number__c = testAudit.Id, of_months__c = 1, StageName = 'Not Yet Proposed', CloseDate = system.today(), Implementer__c = 'Andrew Bettke', Double_Checker__c = 'Andrew Bettke', Expected_Completion_Initial_Validation__c = system.today());
        insert testSavingsItem;
        
        PageReference testPage = new PageReference('/apex/SIBInvoiceWizard?accId='+testAccount.Id);
        Test.setCurrentPage(testPage);
        
        
        Test.startTest();
        
        SIBInvoiceWizard wizardController = new SIBInvoiceWizard();
        
        wizardController.invoice.Name = '123456';
        wizardController.invoice.Invoice_Date__c = system.today();
        //wizardController.aWrappers[0].savingsWrappers[0].sibe.CV_Billed__c = 100;
        //wizardController.aWrappers[0].savingsWrappers[0].sibe.of_Months_Included__c = 1;
        //wizardController.aWrappers[0].savingsWrappers[0].included = true;
        //wizardController.calculateBillingAllocations();
        wizardController.formSubmission();
        
        Test.stopTest();
        
    }
}


 
I created a visualforce page that is currently being used as a custom home page for certain users(Sales Reps) to get around the 3 component limit on the home page dashboard. The page has 9 different reports using the analytics:reportChart component. This strategy worked for a couple months until a month or 2 ago when one of the reports just stopped loading and started throwing this error. 

"You can’t view the report chart because of an error. If the problem continues, contact salesforce.com Customer Support with as much information as you have, including the error code {0}, so that we can try to reproduce and fix the problem."


Below is the Visualforce code that I used. The report that is causeing all the issue is the first entry on the second set"00OC0000005glVf". I checked and that link is valid and brings up the report. 



As added info, this is not a joined or matrix report.
<apex:page >

	<apex:sectionHeader title="Sales Dashboard 2.0"/>
	<apex:outputPanel id="charts" title="Charts" layout="block" style="width:75%;">
	
	<style type="text/css">
	    #chartTable {margin-left: auto; margin-right: auto;}
	    #chartTable td {text-align: center; font-weight: bold;}
	</style>
		<div id="chartTable">
			<table>
				<tr>
					<td><analytics:reportChart reportId="00OC0000005jY9D" size="medium" cacheResults="false" showRefreshButton="false"/></td>
					<td><analytics:reportChart reportId="00OC0000005jY2R" size="medium" cacheResults="false" showRefreshButton="false"/></td>
					<td><analytics:reportChart reportId="00OC0000005jYBi" size="medium" cacheResults="false" showRefreshButton="false"/></td>
				</tr>
				<tr>
					<td><analytics:reportChart reportId="00OC0000005glVf" size="medium" cacheResults="false" showRefreshButton="false"/></td>
					<td><analytics:reportChart reportId="00OC0000006LQ9J" size="medium" cacheResults="false" showRefreshButton="false"/></td>
					<td><analytics:reportChart reportId="00OC0000005jY8e" size="medium" cacheResults="false" showRefreshButton="false"/></td>
				</tr>
				<tr>
				</tr>
				<tr>
					<td><analytics:reportChart reportId="00OC0000005jYBE" size="medium" cacheResults="false" showRefreshButton="false"/></td>
					<td><analytics:reportChart reportId="00OC0000006M7JG" size="medium" cacheResults="false" showRefreshButton="false"/></td>
					<td><analytics:reportChart reportId="00OC0000006M7JH" size="medium" cacheResults="false" showRefreshButton="false"/></td>
				</tr>
			</table>
		</div>
	</apex:outputPanel>

</apex:page>

 
I have a visualforce page that we are using as a custom home page for our Sales Reps to get around the 3 component limit on home page dashboards. The page displays 9 different report charts using the analytics:reportChart componenent. This has worked succesfully for months until just recently one of the reports stopped loading and starting generating the following error:

You can’t view the report chart because of an error. If the problem continues, contact salesforce.com Customer Support with as much information as you have, including the error code {0}, so that we can try to reproduce and fix the problem.

Below is the VF page used. The problem child is in the second row, first entry with reportId = 00OC0000005glVf. Yes, I have already verified that I am using the correct report Id. Also, this is not a joined or matrix report. Just a simple summary report with a report chart. Sorry about image, the forums was code sample function was not inserting my code correctly.

Code Sample
Ok, so I know Salesforce has a lot of really weird (and most of the time stupid) limitations when it comes to things but this one seems non-sensical. I had little help over on the success forums.

I'm creating a custom home page for some of my users using a visualforce page. On the visualforce page will be 9 'Analytic Report Charts' that refernce to pre-made reports in Salesforce. I've gotten the components to work with 7 out of 9 reports. The 2 it doesn't work for are joined reports. However, these reports have charts in them. Why can't  it pull this chart into my visualforce page! Why are joined reports not compatible with this component? Isn't simple enough to pull in the chart that I've already made?
I'm trying to make a button that exectues Javascript to update activites. The javascript reaches out and executes an apex webservice method but would like to pass in a couple parameters; and ID and and Integer. I've written the code below but get an error when declaring int as a parameter. It says it is an invalid type. Any thoughts?

global class PullLeadActivies {
//This is used on a button for Leads
//When a sales rep clicks the button it creates a new completed activity "Left VM"
//This class pulls the first open activity from the lead and sets it to Tomorrow

webservice static void updateOpenActivities(ID LeadID, int days){
  List<Task> tasks = new List<Task>();
  //get a list of open tasks
  tasks = [SELECT ID, ActivityDate From Task Where WhoId = :LeadID AND Status = 'Not Started'];
  if (tasks.size() > 0) {
   //set the due date to be days
   tasks[0].ActivityDate = system.today().addDays(days);
   update tasks[0];
  }
 
}
}
Hi,

I have a custom object.I have two fields, SIB Sales Rep(Contact lookup field) and stage(picklist).I want to create an automated activity for the person listed in the "Primary Sales Rep" field when the stage picklist has a value "Closed/ Won".I know this can be done by writing apex trigger.However, I am new to apex code.If somebody could help me with the code, that would be great.

Thanks
Hi,
I am new to Salesforce testing.When I try to push a trigger class it says your code coverage is below 75%.I need to deploy it urgently.I tried running all tests and by going to developer console to check code coverage for each class.
Here is the screenshot
User-added image

I am thinking if I could exclude the classes with miminal coverage from the code coverage so that they do not lower the overall code coverage.I tried that by annotating each class by @isTest but even after that when I tried run all tests and went to develop console I could still see those classes with 0% coverage.
Need a report that indicates how much API each app and each person consumed on monday 9th october that exceeded our API limit.

organization id: 00D80000000aSjb
Hi,

I am trying to create a subsection in opportunity object that has two fields inside it.

1. Escalating Invoice Collection to SIB (checkbox)
2. Invoice Collection Escalation Notes (textbox)

I have written an apex code for that
<apex:page standardController="Opportunity" tabStyle="Opportunity">

<script>
function colorPageBlock(pageblock, color) {
if (pageblock != null) pageblock.firstChild.style.cssText = “background-color: ” + color + “;”;

}
</script>


<apex:form >


    <apex:pageBlock >

        <apex:pageBlockSection id="blueSection" title="Outsource Team Information">
            <apex:inputField value="{!opportunity.Escalating_Invoice_Collection_to_SIB__c}"/><tr></tr>
            <apex:inputField value="{!opportunity.Invoice_Collection_Escalation_Notes__c}"/>
            <script>colorPageBlock(document.getElementById("{!$Component.blueSection}"), "blue");</script>
        </apex:pageBlockSection>

    </apex:pageBlock>

</apex:form>

</apex:page>

But I am unable to edit the fields since this visualforce page does not show up on edit page layout and I can't even edit this on detail page as there is no save option.(Screenshot attached)

User-added image

Also, I want to change the color of "Outsource Team Information" bar from yellow to blue .

User-added image
I have a picklist in salesforce with API name "No_Penalty__c".It has different options e.g 30 Day Out, 45 Day Out, 60 Day Out and then I have an angular page where I have to display the text based on what option user selects from that picklist.So e.g if user selects 30 Day Out, on the angular page I should see "Agreement may be cancelled with no penalty upon 30 days' written notice".Similarly, if user selects 60 Day Out from the picklist then on the Angular page it should display "Agreement may be cancelled with no penalty upon 60 days' written notice".I tried doing the following
                           <div ng-show="No_Penalty__c === '30 Day Out'">
                                <b>Agreement may be cancelled with no penalty upon 30 days' written notice</b>
                           </div>

                            <div ng-show="No_Penalty__c === '60 Day Out'">
                                <b>Agreement may be cancelled with no penalty upon 60 days' written notice</b>
                           </div>

But then it displays both texts on the angular page irrespective of what option is selected in picklist.
I've just finished re-factoring some an old apex controller I wrote a while back. Field testing in the sandbox as far as functionality has shown it works great. Now I'm trying to write the test class for it and I'm having some serious issues. I'm unable to call any of the local variables from within the class. The test class stops running once it reaches line the creation of the aWrappers. It's like it doesn't query for any of the opportunities that are related to the audits. Any help would be greatly appreciated.

Apex Controller
/**
 * Author: Andrew Bettke
 * Date: 12/8/14
 * Last Revision: 10/21/2015
 *
 * The controller handles the 'SIBInvoiceWizard' custom visualforce page. This page will be used by the accounting department to mass create SIB Invoices
 * (along with billing event records) quickly and seamlessly from one page. The page will be accessed from a button on any active client account detail
 * page. From there, the page will dynamically displays editable data tables for each savings item that can billed for that month. After submitting the
 * form with, the controller will analyze the data and created invoice and billing event records accordingly. 
 **
 */
 
public class SIBInvoiceWizard {
	
	//The account for which we will be generating an invoice.
	public Account account {get; set;}
	
	//All audits processing savings for this account.
	
	public List<auditWrapper> aWrappers {get; set;}
	public SIB_Invoice__c invoice {get; set;}
	public Decimal invoiceTotal {get; set;}
	public Decimal inputTotal {get; set;}
	private static set<String> variableSavingsSources = new set<String> {'Generic VoIP Proposal','Plan Optimization',
																		 'Rate Reduction','Service Standardization',
																		 'Vendor Change','Vendor Consolidation'};
	
	//Upon creation, initialize variables and fill lists.
	public SIBInvoiceWizard(){
		
		
		//Instantiate the account by querying the database for the specified ID
		account = [SELECT ID, Name FROM Account Where Id = :ApexPages.currentPage().getParameters().get('accId')];
		
		//Instantiate the Invoice and link it to the Account.
		invoice = new SIB_Invoice__c();
		invoice.Account__c = account.Id;
		invoice.Amount_Paid__c = 0;
		invoiceTotal = 0.00;
		inputTotal = 0.00;
		
		//Grab a list of all relevant audits and their savings to fill the savings and audit wrappers.
		List<Location_Audits__c> auditsWithSavings = [SELECT Id, Name, Stage__c, Audit_Type__c,
									(SELECT ID, Name, Savings_Source__c, Type, Amount, Monthly_Contract_Value__c, CV__c, CV_Total_Billed__c, 
									        CV_Remaining__c, of_Months_Remaining__c, Recurrence_Type__c, Account.Contingency_Fee__c //Sub-query
									 FROM Opportunities__r
									 WHERE (StageName = 'Finalized Savings' OR StageName = 'Engagement Complete') AND CV_Remaining__c > 0)
							 FROM Location_Audits__c 
		                     WHERE Account__r.Id = :account.Id];
		 
		//Create a new list of auditWrappers and fill those auditWrappers with audits from the list above and a list of savingsWrappers.                    
		aWrappers = new List<auditWrapper>();
		for(Location_Audits__c audit : auditsWithSavings){
			List<savingsWrapper> sWrappers = new List<savingsWrapper>();
			for(Opportunity savingsItem : audit.Opportunities__r){
				Savings_Item_Billing_Event__c newSIBE = new Savings_Item_Billing_Event__c();
				newSIBE.Savings_Item__c = savingsItem.Id;
				newSIBE.CV_Billed__c = 0;
				sWrappers.add(new savingsWrapper(savingsItem,newSIBE));
			}
			if(sWrappers.size() > 0){
				aWrappers.add(new auditWrapper(audit,sWrappers));
			}
			
		}
		
	}
	
	public void calculateBillingAllocations(){
		for(auditWrapper a : aWrappers){
			Decimal adjustedCategoryBilling = a.categoryBillingTotal;
			Decimal includedVariableTotal = 0.00;
			//First Loop: Assign fixed billing amounts for one-time savings and fixed monthly savings.
			//While looping, sum the amounts for all included variable savings.
			for(savingsWrapper s : a.savingsWrappers){
				if(s.included == true){
					//We have a one-time or fixed montly savings item.
					if(!variableSavingsSources.contains(s.savingsItem.Savings_Source__c) ){
						s.allocationPercent = 100.00;
						s.sibe.CV_Billed__c = (s.savingsItem.Amount * (s.savingsItem.Account.Contingency_Fee__c/100)).setScale(2,RoundingMode.HALF_UP);
						adjustedCategoryBilling = adjustedCategoryBilling - s.sibe.CV_Billed__c;
					} else{
						includedVariableTotal = includedVariableTotal + s.savingsItem.Amount;
					}
				} else{
					s.allocationPercent = 0.00;
					s.sibe.CV_Billed__c = 0.00;
				}
			}
			
			//Second Loop: Assign allocated billing amounts for variable monthly savings.
			for(savingsWrapper s : a.savingsWrappers){
				if(s.included == true && includedVariableTotal > 0){
					//We have a variable monthly savings item
					if( variableSavingsSources.contains(s.savingsItem.Savings_Source__c) ){
						//Calculate the allocation % for the remaining amount of billing left to allocate.
						s.allocationPercent = ((s.savingsItem.Amount/includedVariableTotal) * 100).setScale(2,RoundingMode.HALF_UP);
						s.sibe.CV_Billed__c = (adjustedCategoryBilling * (s.allocationPercent/100)).setScale(2,RoundingMode.HALF_UP);
					}
				}
			}
		}
		
		invoiceTotal = 0.00;
		inputTotal = 0.00;
		for(auditWrapper a : aWrappers){
			inputTotal = inputTotal + a.categoryBillingTotal;
			for(savingsWrapper s : a.savingsWrappers){
				invoiceTotal = (invoiceTotal + s.sibe.CV_Billed__c).setScale(2,RoundingMode.HALF_UP);
			}
		}
		
		if(invoiceTotal != inputTotal){
			ApexPages.addMessage( 
								 new ApexPages.Message(ApexPages.Severity.ERROR,'The amount recieved from data entry does not match the calculated invoice total. Review your input and recalculate.')
								);
		} else{
			ApexPages.addMessage( 
								 new ApexPages.Message(ApexPages.Severity.CONFIRM,'The input total and calculated invoice total match! You may proceed with submission.')
								);
		}
	}
	
	
	//Called when the form is submitted.
	public PageReference formSubmission(){
		//Insert the created invoice into the database
		try{
			insert invoice;
		
			//Link each billingEvent created back to the newly inserted invoice, then insert the billing events.
			Integer lineItem = 1;
			for(auditWrapper a : aWrappers){
				for(savingsWrapper s : a.savingsWrappers){
					s.sibe.SIB_Invoice__c = invoice.Id;
					if(lineItem < 10){
						s.sibe.Name = invoice.Name + ' - 0' + lineItem;
					} else{
						s.sibe.Name = invoice.Name + ' - ' + lineItem;
					}
					
					if(s.sibe.CV_Billed__c != null || s.sibe.CV_Billed__c == 0){
						insert s.sibe;
						lineItem = lineItem + 1;
					}
				}
			}
			
			//Create a new page reference for the invoice and redirect the user to the newly created invoice.
			PageReference invoiceDetail = new PageReference('/'+invoice.Id);
			invoiceDetail.setRedirect(true);
			return invoiceDetail;
		} catch(DmlException e){
			if( e.getMessage().contains('DUPLICATE_VALUE') ){
				ApexPages.addMessage( 
								 new ApexPages.Message(ApexPages.Severity.ERROR,'Duplicate Invoice ID found. This Invoice # already exists.')
								);
				return ApexPages.currentPage();
			} else{
				ApexPages.addMessage( 
								 new ApexPages.Message(ApexPages.Severity.ERROR,'A generic DML exception has occured. Please contact the system administrator.')
								);
				return ApexPages.currentPage();
			}
			
		} catch(Exception e){
			ApexPages.addMessage( 
								 new ApexPages.Message(ApexPages.Severity.ERROR,'A generic exception error has occured. Please contact the system administrator.')
								);
			return ApexPages.currentPage();
		}
	}
	
	
	class auditWrapper{
		
		public Location_Audits__c audit {get; set;}
		public List<savingsWrapper> savingsWrappers {get; set;}
		public Decimal recurringVariableTotal {get; set;}
		public Decimal categoryTotal {get; set;}
		public Decimal categoryBillingTotal {get; set;}
		
		public auditWrapper(Location_Audits__c audit, List<savingsWrapper> savingsWrappers){
			this.audit = audit;
			this.savingsWrappers = savingsWrappers;
			this.categoryTotal = 0;
			this.categoryBillingTotal = 0.00;
		}
		
	}
	
	class savingsWrapper{
		
		public Opportunity savingsItem {get; set;}
		public Savings_Item_Billing_Event__c sibe {get; set;}
		public Decimal allocationPercent {get; set;}
		public Boolean included {get; set;}
		
		public savingsWrapper(Opportunity savingsItem, Savings_Item_Billing_Event__c sibe){
			this.savingsItem = savingsItem;
			this.sibe = sibe;
		}
		
	}

	
}

Visualforce Page
<apex:page controller="SIBInvoiceWizard" docType="html-5.0">
	
	<apex:includeScript value="/soap/ajax/29.0/connection.js"/>
	<apex:includeScript value="/soap/ajax/29.0/apex.js"/>
	    	
	<style type="text/css">
	
	    
		.col-md {
			width:10%;
		}
		.col-sm {
			width:5%;
		}
		
		.totals td{
	    	font-weight:bold;
	    }
	    
	    .totals .col1{
	    	width:77%;
	    }
	    
	
	</style>   
	    	
	
		<apex:pageMessages />
		<apex:sectionHeader title="SIB Invoice Wizard"/>
			
			<apex:form id="wizardForm">
			
				<apex:PageBlock id="invoiceDetails" title="Invoice Details">
					<table style="table-layout:fixed;width:50%;">
						<tr>
							<td>
								<apex:outputLabel value="Invoice # " style="font-weight:bold"/>
							</td>
							<td>
								<apex:outputLabel value="Invoice Date " style="font-weight:bold"/>
							</td>
							<td>
								<apex:outputLabel value="Amount Paid " style="font-weight:bold"/>
							</td>

						</tr>
						<tr>
							<td>
								<apex:inputField id="invoiceNumber" value="{!invoice.Name}"  required="true"/>
							</td>
							<td>
								<apex:inputField id="invoiceDate" value="{!invoice.Invoice_Date__c}"/>
							</td>
							<td>
								<apex:inputField id="amountPaid" value="{!invoice.Amount_Paid__c}"/>
							</td>
						</tr>
					</table>
					
					
				</apex:PageBlock>
				
				<apex:PageBlock id="savingsForm" onkeyup="totalBillingEvents();">
				
					
						<apex:repeat value="{!aWrappers}" var="a">
	
							<apex:pageBlockSection title="{!a.audit.Name + ' (' + a.audit.Audit_Type__c + ')'}" columns="1">
						
								<apex:outputPanel layout="block" style="width:100%;" id="savingsTables">
								
								<table>
									
									<tr>
										<th class="col-md">Name</th>
										<th class="col-md">Savings Source</th>
										<th class="col-sm">Type</th>
										<th class="col-sm">Recurrence Type</th>
										<th class="col-sm">Allocation Factor</th>
										<th class="col-sm">Monthly Savings</th>
										<th class="col-sm">Monthly CV</th>
										<th class="col-sm">CV Billed</th>
										<th class="col-sm">CV Remaining</th>
										<th class="col-sm">Current Billing</th>
										<th class="col-sm"># of Months Included</th>
										<th class="col-sm">Item Included</th>
									</tr>
									
									<apex:repeat value="{!a.savingsWrappers}" var="s">
									<tr>
										<td class="col-md"><apex:outputLink value="/{!s.savingsItem.Id}">{!s.savingsItem.Name}</apex:outputLink></td>
										<td class="col-md">{!s.savingsItem.Savings_Source__c}</td>
										<td class="col-sm">{!s.savingsItem.Type}</td>
										<td class="col-sm">{!s.savingsItem.Recurrence_Type__c}</td>
										<td class="col-sm">{!s.allocationPercent}%</td>
										<td class="col-sm">${!s.savingsItem.Amount}</td>
										<td class="col-sm">${!s.savingsItem.Monthly_Contract_Value__c}</td>
										<td class="col-sm">${!s.savingsItem.CV_Total_Billed__c}</td>
										<td class="col-sm">${!s.savingsItem.CV_Remaining__c}</td>
										<td class="col-sm">
											<apex:outputText value="{0, number, currency}" style="width:70%;">
												<apex:param value="{!s.sibe.CV_Billed__c}"/>
											</apex:outputText>
										</td>
										<td class="col-sm"><apex:inputField value="{!s.sibe.of_Months_Included__c}" style="width:25%;"/></td>
										<td class="col-sm"><apex:inputCheckbox value="{!s.included}" style="text-align:center;"/></td>
									</tr>
									</apex:repeat>
									
									
									<tr class="totals">
										<td  colspan="9">Total Billed for Audit Category</td>
										<td><apex:inputText value="{!a.categoryBillingTotal}" style="width:70%;"/></td>
									</tr>
									
								</table>
										
								</apex:outputPanel>
	
							</apex:pageBlockSection>
							
						</apex:repeat>
						
					<apex:pageBlockSection columns="1">
					<apex:outputPanel layout="block" style="width:100%;">
						<table class="totals" style="width:100%;margin-top:2%">
							<tr>
								<td class="col1">Invoice Total</td>
								<td><apex:outputText value="{0, number, currency}" style="color:{!IF(invoiceTotal==inputTotal,'green','red')};">
										<apex:param value="{!invoiceTotal}"/>
									</apex:outputText>
								</td>
							</tr>
							<tr class="totals">
								<td class="col1">Billing Input Total</td>
								<td><apex:outputText value="{0, number, currency}">
										<apex:param value="{!inputTotal}"/>
									</apex:outputText>
								</td>
							</tr>
							<tr>
								<td class="col1"></td>
								<td><apex:commandButton value="Calculate" rerender="" action="{!calculateBillingAllocations}"/></td>
							</tr>
							<tr>
								<td class="col1"></td>
								<td><apex:commandButton value="Submit" rerender="" action="{!formSubmission}" disabled="{!(invoiceTotal=0 ||
																														   inputTotal=0 ||
																														   invoiceTotal != inputTotal)
																														}"/>
								</td>
							</tr>
						</table>
					</apex:outputPanel>
					</apex:pageBlockSection>
					
				</apex:PageBlock>
				
			</apex:form>
			
			<script type="text/javascript">
		
				function totalBillingEvents(){
					var itemAmountElements = document.getElementById("{!$Component.wizardForm.savingsForm}").getElementsByTagName("input");
					var total = 0;
		
					for(i = 0; i < itemAmountElements.length; i++){
						var currency = itemAmountElements[i].value;
						var number = Number(currency.replace(/[^0-9\.-]+/g,""));
						total = total + number;
						i = i + 1
					}
					
					document.getElementById("{!$Component.wizardForm.savingsForm.invoiceTotal}").innerHTML = "$"+total.toFixed(2);
				}		
		
			</script>
	
	</apex:page>
Apex Test Class
/**
 *
 */
@isTest
private class SIBInvoiceWizardTest {

    static testMethod void SIBInvoiceWizardMainTest() {
        Account testAccount = new Account(Name = 'Test Account', RecordTypeId = '012C0000000GCJv', Industry = 'Banking',Status__c = 'Active');
        insert testAccount;
        
        Location_Audits__c testAudit = new Location_Audits__c(Account__c = testAccount.Id, Stage__c = 'Audit Complete - Processing Savings', Audit_Type__c = 'CO2', Current_Analyst__c = 'Andrew Bettke');
        insert testAudit;
        
        Opportunity testSavingsItem = new Opportunity(Name = 'testSavings', Account = testAccount, Audit_Number__c = testAudit.Id, of_months__c = 1, StageName = 'Not Yet Proposed', CloseDate = system.today(), Implementer__c = 'Andrew Bettke', Double_Checker__c = 'Andrew Bettke', Expected_Completion_Initial_Validation__c = system.today());
        insert testSavingsItem;
        
        PageReference testPage = new PageReference('/apex/SIBInvoiceWizard?accId='+testAccount.Id);
        Test.setCurrentPage(testPage);
        
        
        Test.startTest();
        
        SIBInvoiceWizard wizardController = new SIBInvoiceWizard();
        
        wizardController.invoice.Name = '123456';
        wizardController.invoice.Invoice_Date__c = system.today();
        //wizardController.aWrappers[0].savingsWrappers[0].sibe.CV_Billed__c = 100;
        //wizardController.aWrappers[0].savingsWrappers[0].sibe.of_Months_Included__c = 1;
        //wizardController.aWrappers[0].savingsWrappers[0].included = true;
        //wizardController.calculateBillingAllocations();
        wizardController.formSubmission();
        
        Test.stopTest();
        
    }
}


 
I have a visualforce page that we are using as a custom home page for our Sales Reps to get around the 3 component limit on home page dashboards. The page displays 9 different report charts using the analytics:reportChart componenent. This has worked succesfully for months until just recently one of the reports stopped loading and starting generating the following error:

You can’t view the report chart because of an error. If the problem continues, contact salesforce.com Customer Support with as much information as you have, including the error code {0}, so that we can try to reproduce and fix the problem.

Below is the VF page used. The problem child is in the second row, first entry with reportId = 00OC0000005glVf. Yes, I have already verified that I am using the correct report Id. Also, this is not a joined or matrix report. Just a simple summary report with a report chart. Sorry about image, the forums was code sample function was not inserting my code correctly.

Code Sample