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
ani123ani123 

Apex Trigger Help to calculate Previous yr Balance Amt+CurrentAmt

Hi,

 

I have Custom Object Annual Charge__C.

 

Field Name: Previous Balance Amt_c.

 

Annual charges created based on Year For Example :AC-2011,AC-2012,AC-2013,AC-2014,AC--2015.

 

for each year balance amount will be displayed in  a field name  :BalanceAmt__c.

 

My Requirement:This Trigger should fire on after insert /after update of Annual charge Object


For Example If, I INSERT A RECORD  AC-2011 Balance  Amount  = 700

Then in Previous Balance Amt_c=700 should display (This is calculated as Previous yr Balance+ Current yr of the selected record (i.e)

 

In this Example there is no Annual Charge  Before 2011 there is no record ,so Previous Balance will be 0 + SELECTED YR is 2011 (Balance Amt of 2011 is 700)

 

 

Same will be Continued as,

AC-2011

if,Balance Amt =700

Previous Balance Amt = 700

 

AC-2012

if,Balance Amt =1000

Previous Balance Amt =( Previous  yr amt 2011+2012 yr Balance Amt )=700+1000=1700

 

'

'

 

'

 

'

'

 

'

Kindly help me with this.

 

Thanks in Advance:)