Calculated value in form field not showing up in Report.

Calculated value in form field not showing up in Report.

Hi,

I wrote a small script to calculate a CURRENT DUE value based on a few other fields. The script is below.
I have it attached to run when a user EDIT’s the form. It works fine in this context.

However, when I create a report and include this field  (CURRENT DUE) in it, the value is incorrect. Sometimes it’s zero, other times it’s another value. But in every case so far it’s not the correct value.

Do I need to attached this script to a different user action to have the CURRENT DUE value appear correctly in the report I am creating? The report is a basic report. No Custom Actions. It’s just trying to display the value of the CURRENT DUE (currentDue) field.

I had assumed that when the script ran below, the value calculated for ‘currentDue’ would be saved in the DB under the field ‘currentDue’ and pulling that value from any report would be consistent with the last updated value of ‘currentDue'

Thanks,
Mike






// This runs when a user loads a record to edit it.
input.currentDue = 0.0;
input.currentDue = (input.Tuition  -  input.Scholarship  -  input.Deposit);
if ((input.p1rec.toString()  ==  "Payment 1 Received")  &&  (input.p1amt  !=  null))
{
    input.currentDue = (input.currentDue  -  input.p1amt);
}
if ((input.p2rec.toString()  ==  "Payment 2 Received")  &&  (input.p2amt  !=  null))
{
    input.currentDue = (input.currentDue  -  input.p2amt);
}
if ((input.p3rec.toString()  ==  "Payment 3 Received")  &&  (input.p3amt  !=  null))
{
    input.currentDue = (input.currentDue  -  input.p3amt);
}
if ((input.p4rec.toString()  ==  "Payment 4 Received")  &&  (input.p4amt  !=  null))
{
    input.currentDue = (input.currentDue  -  input.p4amt);
}
if ((input.p5rec.toString()  ==  "Payment 5 Received")  &&  (input.p5amt  !=  null))
{
    input.currentDue = (input.currentDue  -  input.p5amt);
}
if ((input.p6rec.toString()  ==  "Payment 6 Received")  &&  (input.p6amt  !=  null))
{
    input.currentDue = (input.currentDue  -  input.p6amt);
}