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
caanguscaangus 

rollup of billing events per project

Hello,

 

We've reached out limit of Rollups on our Project object. I need to code a roll up manually.

 

My goal is to calculate the total of all billing events per Project and update a field on Project called "Total Invoiced to Date". I'm trying to figure out the suedo code before I begin and would greatly appreciate any info more experienced coders can give. I believe it should look something like

 

trigger trg_RollupBillgEventsToProject on CCI_Invoice__c (after delete, after insert) {
	
	//*********************************
	//CCI_Project__c is parent (record to be updated)
	//CCI_Invoice__c is the roll-up object (counting the total invoiced to date and adding them to the parent record)
	
	//Create a variable to hold the total of billing events associated with the project
	double dblTotalBillingEvents = 0;
	
	//CCI_Project__c is Parent (record to be updated)
	//CCI_Invoice__c is the roll-up object (counting the sum of Total_Invoice_Value__c in all billing events)
	
	//Create a new instance of the Project Object
	CCI_Project__c [] projectToUpdate = new CCI_Project__c[]{};
	
	//******************************
	//New Records
	//******************************
	if(Trigger.isInsert||Trigger.isDelete){
		
		if(Trigger.isInsert){
			
			for(CCI_Invoice__c be: childObjectNew ){

				!!! How would I collect the billing events? !!!!

				dblTotalBillingEvents += be.Total_Invoice_Value__c;
			}

			projectToUpdate.Total_Invoiced_to_date = dblTotalBillingEvents;
		}
	}
}
                   

 Above I'm trying to figure out the insert first, than I'll move on to updates and deletes.

 

Thanks!

Vinit_KumarVinit_Kumar

Hi,

 

Try the below link:-

 

http://www.anthonyvictorio.com/salesforce/roll-up-summary-trigger/

 

Basically,you need a roll up summary trigger and the above link will show from scratch as how you can get it.

davidjgriffdavidjgriff

You could also contact Support to see if the Rollup Limit can be increased. Depending on the business case, they may be able to help out.