These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Live Cycle Design Subform Question

jtaylor46
Registered: Jun 13 2008
Posts: 14
Answered

I have been searching/googling and read various scripting
tutorials on Adobe.com but haven't located a solution for my
problem (both Java and FormCalc). I have created a table that has 9 columns (date, application number (autonumbered), household size(drop
down), vendor (drop down), pending, approved, received (all
check boxes), approved amt (calculated), payment amt
(calculated), adjusted amt (calculated), tentative balance
(calculated), actual balance (calculated) and additional
funds (calculated).

The tentative balance is calculated by (Additional funds -
approved amount + adjusted amt). The actual balance is
calculated by (Additional funds - Payment amt). Additional
funds are not entered on each entry - only when the state
provides new funding must is needed for the worker to be
able to add in the funds when allocated.

There are add and remove buttons so the form can expand as
an application is taken.

My problem - I need to have the tentative and actual
balances have actual running balances based on the results
after the calculations are completed for the previous row
and use these calculations at the beginning of the
calculations for the next row. As an example: If my
addtional funds entered is $5000.00 and I end up with a
tentative balance of $4,800 and and actual balance of
$5000.00 (as final payment has not been made), when the user
begins to enter a new application, I need the balances to
come forward.

All the calculations/scripts in the form work fine. I just
need to know how to have the expanding rows include the
tentative, actual and additional funding (even if null)
forwarded to the added/del rows while calculating accordingly. Essentially, I want to create a running ledger that allows a running tentative and actual balance along with calculating in any additional funds that may be entered.
Currently, the additional funds field is defaulted to zero but user can update.

Would you have any suggestions to assist me with this?
Thank you.

Josephine

My Product Information:
LiveCycle Designer, Windows
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
Each instance of the Row Subform has an index. Use this index in the "resolveNode" function to include values from the previous row into calculations in the current row.

For example, this code is for a calculation on a field in table row.

var prevValue = 0;var prevIndex = this.parent.index -1;// The first row does not have a previous value;if(prevIndex >= 0){var prevBalance = MajorSubform.resolveNode("RowSubform[" + prevIndex + "].balance"); prevValue = prevBalance.rawValue;}

Where "MajorSubForm" is the subform that holds the row subforms, "RowSubForm", and "balance" is a field in the row.

Also take a look at this video:
https://admin.adobe.acrobat.com/_a200985228/p87746471/

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

jtaylor46
Registered: Jun 13 2008
Posts: 14
Thank you Thomp for your response. A couple of questions - first I have my fields in a table on a single line - this would impact the coding correct? Secondly, my hierachy is form1.Table7.Data1 for the row that is repeating in the subform - I would replace this where you have the MajorSubform notation in the code? this calculations that I have for the field should be substituted in the preValue field? Thank you
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
In my code, "MajorSubform" is the subform that contains the entire table and "RowSubform" is a line, or row, in the table. If you created the table using the Designer "Table" tool then you probably have another level of hierarchy for the table cells.

You want the field to get the index of it's parent "Row" subform since this is the repeated subform. To do this the code may have to go up two levels of hierarchy. i.e., "this.parent.parent.index".

To find the previous field with "resolveNode", you need to start with a known node above the table rows. So you could start with "Table7".

Table7.resolveNode("data1....");

Be sure to watch that video. It covers a lot of this material.

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

jtaylor46
Registered: Jun 13 2008
Posts: 14
Thomp, I have gone through the video and unless I am missing the mark here it appears I need to place the similar calculation fields in a subform in the template and then rearrange. It appears as though it would be better to use java to create the fields instead of the table property. I am not certain how to attach the form so you can look at it and tell me what I'm missing. When I input the script it does not appear to calculate forward in the TenativeBal field or the Acutal Balance fields. I need to the AddtFunds field to be added in at any time data is entered in.

If you would let me know how I can email/attach the form, I would really appreciate it if you would take a look and see if it is the table, or the first calculation that may be hindering the script if you would be so kind.

Thank you for your patience and tolerance with this.

Sincerely, Josephine
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
Adobe has a new file transfer service they're trying out, it's in Beta. Goto www.acrobat.com and click on share.

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

jtaylor46
Registered: Jun 13 2008
Posts: 14
This particular script is not working to pull the previous record balance to recalculate the current record balance in an expanding subform. Possibly it has to do with the problems in Acrobat 8.0 LC with the resolvenode glitch that I understand is addressed in version 9.

I have recreated my form in another application and all functions work well. You can have the greatest application in the world but it loses its greatness when simple business functions are this involved. I will continue to work on the form until I create the script that performs the function as time allows. As I have been using LC for over two years and have dynamic forms on a State website, I am dismayed with this particular experience. As a long time end user/programmer and developer of forms, it has altered my impression of the functionality of this application.

jtaylor
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
I think you are missing something. As a test I created a form with exactly the features you are working on and didn't have any problems.

Since I haven't seen your form I can only guess at the issue. But I imagine that the problem is a code error, most likely somthing in the hierarchy. I do not believe that a bug in Acrobat (and there are a few) is causing the problem.

The best way to approach debugging is to break the problem down into small parts that you can easily verify and then narrow the focus to a single issue. I use large quantities of "console.println()" statements in my code for doing this. For example, is the field previous line being acquired correctly? This is a single issue you can test for outside of everything else on the form.

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

jtaylor46
Registered: Jun 13 2008
Posts: 14
Thom, I recreated my data in text fields. My form has a header wrapped in a subform. Then a table row is wrapped in a subform and contains the column headings only so it is only one line. Below this are my new text/numeric fields. The first numeric field is an auto number field. It is separated from my fields that I need to pull the previous balance from. I thought possibly this could be the problem but I tried the script with and without the auto number function and get the same result. The script below is the script that I currently have under the calculated event for the first field that I need to pull the previous data from. It doesn't give any errors but it provides no results. Any idea of what it is missing?


--- form1.P1.Info.NumericField3::calculate: - (JavaScript, client) -------------------------------
var prevValue = 0;
var prevIndex = this.parent.index -1;
//The first row does not have a previous value;
if(prevIndex >= 0)
{
var prevBalance = xfa.form.P1.resolveNode("Info[" + prevIndex + "].NumericField3.rawValue") + TextField6.rawValue - TextField4.rawValue + NumericField2.rawValue;
prevValue = prevBalance.rawValue;
}
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
Ok, End the first line with a ";", not a "+". You're mixing in the aquisition of the previos field with an addition.

like this (for the code in the if)
   var prevBalance = xfa.form.P1.resolveNode("Info[" + prevIndex + "].NumericField3.rawValue");prevValue = prevBalance.rawValue;this.rawValue =  preValue + TextField6.rawValue - TextField4.rawValue + NumericField2.rawValue;

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

jtaylor46
Registered: Jun 13 2008
Posts: 14
Thank you Thomp. I had to modify the script some but was able to get all the functions working properly. I appreciate your help with this. My script ended as follows:

NumericField3.rawValue= NumericField5.rawValue - TextField4.rawValue + NumericField2.rawValue;
var prevIndex = this.parent.index -1;
//The first row does not have a previous value;
if(prevIndex >= 0);
{
var prevBalance = P1.resolveNode("Info[" + prevIndex + "].NumericField3");
var prevValue = prevBalance.rawValue;
NumericField3.rawValue= NumericField5.rawValue - TextField4.rawValue + NumericField2.rawValue + prevValue;
}

Unfortunately when I paste it cuts my lines off. I simply had to modify this script for the other numeric fields.