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
Esmeralda Canoog 3Esmeralda Canoog 3 

Trigger for Rollup summary in a Look up Relationship

Hi All,

I'm not that good with writing codes and I need help on creating a trigger for a rollup summary (Lookup relationship). I have created this in flows but unfortunately, it doesn't work well if there is a huge amount of batch upload . Below are the details:

Sales Discount and FNR object are in look relationship

Sales Discount - Parent and below are fields that we need to pupulate the summarize value:
May A - Number field
May B - Number field
May C - Currency Field
June A - Number field
June B - Number field
June C - Currency Field
July A - Number field
July B - Number field
July C - Currency Field

Etc. until month of December



FNR Object - Child Object of Sales Discount


Months - Picklist field (may, june, july, until Dec.)
A - Number field
B - Number Field
C - Currency Field


Logic is. If (Picklist) months field is May and A, B, C, has a value, it will automatically summarize and be populated in the fields under Salesdiscount which is May A, May B, May C. Same logic with other months like june , july, until december. If the Fnr is deleted,  there's a recalculation of the summarize value as well.

Amy help will be much appreciated.

Thanks
GauravGargGauravGarg
hi Esmeralda,

Can you please explain the Relationship i.e. which is Parent and which is Child object. 
SFDC_DeveloperSFDC_Developer
Instead of writing trigger you can use, Declarative Rollup Summaries (https://appexchange.salesforce.com/listingDetail?listingId=a0N30000009i3UpEAI&tab=r). It is a managed package, which is used for rollup summaries for lookup relationship. It will also save a lot of efforts.
Esmeralda Canoog 3Esmeralda Canoog 3
Hi Guarav,

Sales Discount is the Parent , FNR is the child. I have provided it in my question. Thanks