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
affuaffu 

Automatic Schedule set-off Amount Trigger

Hi all,

Please help me to write a Trigger.

 

In Opportunity i have a related list Schedule

It shows(has) three fields:-

 

Total Receipt Amount Realized - Curreny field, it rollups all the receipts by trigger( this is done)

Installement Basic Value - Currency field

Total Amount Setoff - formula field (Total Amount Realized -Installement Basic Value)

 

Here i want to write a Trigger it should work as below

 

I have three records in Schedule it shows

Schedule NameTotal Receipts Realized       Installement Basic Value       Total Amount Setoff

On Booking                      20000                                       10000                                        10000

Agreement Signing                                   20000                                        5000                                         15000

Excavation                                                   20000                                        5000                                         15000

 

For first record (On Booking) Total Amount Setoff is calculating correctly i.e., 20000-10000=10000 

 

For second record (Agreement Signing) it should take the first records (On Booking) Total Amount Setoff and it should deduct from Installement Basic Value and it should give the Total Amount Setoff in second record Amount as 10000-5000=5000.

The Result should be below mentioned

 

Schedule Name          Total Receipts Realized       Installement Basic Value       Total Amount Setoff

On Booking                              20000                                       10000                                        10000

Agreement Signing                20000                                        5000                                          5000

Excavation                                20000                                        5000                                          0

 

Thanks in advance.....

Schedule