Hey,
I'm a little stuck on a problem with a script that updates a dollar amount and a percentage of an account's balance being paid off when a record is edited in another form - It works fine in the "On Add - On Success" action, which the vast majority of entries would be, but I can't seem to figure out how to get it to work or where to put it when "On Edit"
Here's the script, where the new "Manual Payment Entry - Amount" record adds to the "Payment to Date" in the Contact Form Record, and calculates percentage and remaining balance as well
- if ((input.Method != "Opening Balance (Negative Value Only)") && (input.PayPal_Status != "Pending"))
- {
- balupdate = MHL_Team_Contact_Info_Entry [(Team_Name == input.Team_Name2 && Current_Season == input.Season)];
- balupdate.Payment_To_Date = (balupdate.Payment_To_Date + input.Amount);
- balupdate.Bal_Remain = (balupdate.Opening_Balance_Bal_Fwd - (balupdate.Payment_To_Date + input.Amount));
- balupdate.Pct_Paid = (balupdate.Payment_To_Date / balupdate.Opening_Balance_Bal_Fwd * 100);
- }
The problem here is that if I plug it into the "Edit - On Success" script, the numbers get repeat-entered to the contact, which skews the balance and percentage records, rendering the views based off of it largely useless.
I've tried "On Update" for amount, but this produces the same result. "On Edit - On Load" to deduct the amount prior to any adjustment doesn't work because that skews the balance/percentage negatively even if the user does nothing at all.
What I'd really like is if there's an "On Edit - On Success" script condition that would say essentially "If 'Amount' in this record has been updated, then the application subtracts the amount originally entered/previously updated from the balance/percentage record in the 'Contact Info Entry' record, before updating it with the amount in this update"
Anybody have an idea as to how I should go about this? I'll provide further details to anyone who requests them.
Thanks,
DL