Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

Copying data to another page

Avatar

Level 10

I'm trying to figure out a method to copy required info from table rows (or subforms) to another page. This will be a spreadsheet costing form that we want suppliers to fill out but we only want the used line items to show up on the printing page. There are quite a few line items and there are five columns of data.

I figure this can be done either with a loop looking for "hasValue" in a quantity column or could be done with a button click that activates the rows that are being used.

I'm thinking that on the printing page there would be a table that expands with the selected line items. I don't know of a way to just copy a row to another place though - so I guess one would have to walk the active rows and copy the data from each cell.

Another method would be to have duplicate tables on the printing page with all the rows hidden and only show the rows that have value.

Anyone have any thoughts? Just looking for ideas.

1 Accepted Solution

Avatar

Correct answer by
Level 10

Hi Jono,

Back in one piece 😉

The trouble with the multiple copies of Row1 is that they are not repeating instances of that row. Normally oTable.Row1.instanceManager.count would give us the number of instances. But in this case it just returns 1.

So the following gets all of the objects with the same name (Row1):

for (var j=0; j<=5; j++)

{

     var oTable = xfa.resolveNode("Table1[" + j + "]");

     var rowCount = oTable.Row1.all;

         

     console.println("Rows: " + rowCount.length);

     for (var i=0; i<rowCount.length; i++)

     {

         ... rest of script...

oTable.Row1.all gets all of the instances of Row1 in that table and then the length of this is a number (not zero based).

The form is here: https://acrobat.com/#d=gNYUQyTXQ*aYoHPbIoWJHw

Note that the script will fall over if a row does not have a checkbox, so I have added these in temporarily, where missing in the last body row of the table.

Good luck,

Niall

ps: your coding is solid!!

View solution in original post

7 Replies

Avatar

Level 10

Hi Jono,

How about having a prePrint script to check if the field in the row is null. If it is, the script would hide that row (flowed layout). That way you could just use the one table for data input and printing.

If you need users to print off a blank version of the whole table you could have two print buttons: 'Print blank form' and 'Print completed form'. In this case the check on null would be a loop in the second button.

Just one last thought for the week.

Niall

Avatar

Level 10

Hi Jono,

Here is a sample: https://acrobat.com/#d=hkeDKn6SRo1FAvFUoY6Smw

There are two main print buttons.

The first one hides rows that are blank (well at least if the checkbox is not selected).

The second one hides the first page and displays the second page that has a table with repeatable rows. The script in this button's click event looks at table one and if there the checkbox is selected then it adds an instance and copies the data from table 1.

I have put in a performance indicator (from John Brinkman's examples) and the first option is marginally quicker, particularly if there is lots of data selected.

Good luck,

Niall

Avatar

Level 10

Hey thanks Niall! I'll take a look at it this morning.

Was taking a break from the computer this weekend.

Infiltrated the USA at Port Angeles on Saturday for free beer. So, not a bad

weekend.

Avatar

Level 10

Hey Niall, hoping you're back at your computer.

I'm having trouble extending your script to loop through different tables as

well as the different rows. Eventually I believe we're going to have the

tables hide/show if needed, for now they're all just lumped together in one

subform.

I always seem to get confused when I get into using xfa.resolveNode, etc. My

coding skills still suck.

I've attached the rough form I'm working on.

I have several tables with instance numbers that I want to loop through, it

seems to work ok on the first table but when it's done the first table I get

and error "oRow has no properties" - the code I'm using is (I've tried a

couple variations and am not getting anywhere):

for (var j=0; j<=5; j++)

{

var oTable = xfa.resolveNode("Table1[" + j + "]");

var rowCount = oTable.nodes.length;

for (var i=0; i<rowCount; i++)

{

app.alert("Table: " + j + "  Row: "+ i);

var oRow = xfa.resolveNode("Table1[" + j + "].Row1[" + i + "]");

// var oRow = xfa.resolveNode(oTable + ".Row1[" + i + "]");

if(oRow.CheckBox1.rawValue == "0")

{

oRow.presence = "hidden";

}

}

}

Whoops, thought I was responding to Niall's email address - here's a link to the file: https://acrobat.com/#d=OCyTpCL21iQiJeE-41nmug

Message was edited by: Jono Moore - added file link

Avatar

Correct answer by
Level 10

Hi Jono,

Back in one piece 😉

The trouble with the multiple copies of Row1 is that they are not repeating instances of that row. Normally oTable.Row1.instanceManager.count would give us the number of instances. But in this case it just returns 1.

So the following gets all of the objects with the same name (Row1):

for (var j=0; j<=5; j++)

{

     var oTable = xfa.resolveNode("Table1[" + j + "]");

     var rowCount = oTable.Row1.all;

         

     console.println("Rows: " + rowCount.length);

     for (var i=0; i<rowCount.length; i++)

     {

         ... rest of script...

oTable.Row1.all gets all of the instances of Row1 in that table and then the length of this is a number (not zero based).

The form is here: https://acrobat.com/#d=gNYUQyTXQ*aYoHPbIoWJHw

Note that the script will fall over if a row does not have a checkbox, so I have added these in temporarily, where missing in the last body row of the table.

Good luck,

Niall

ps: your coding is solid!!

Avatar

Level 10

Ah, I thought the instance number on duplicate rows would work the same.

I thought I had run into that at one point - I'll need to figure out a way around that, but maybe setting anything without a checkbox to a footer row will work. Would a try/catch block work to skip the error?

And I always forget about using console.println instead of popups...

Solid like aspic!

Avatar

Level 10

Hi Jono,

You're too hard on yourself

Seriously... The footer rows are OK, they are excluded from the loop. It is just extra body rows that don't (currently) have any description that are causing the problem. Because they are included in the loop, each run is looking for an object in the row called "Checkbox". If it doesn't exist - splat!

Either put in a checkbox or delete that extra body row. You could increase the height of the footer row to highlight the end of the table. I would be inclined to delete the extra rows, then the script will work OK  (it works now, but only with a checkbox in all body rows).

Good luck,

Niall