Expand my Community achievements bar.

Reader Extensions broke my form

Avatar

Level 1

I have a form I designed in Livecycle that has several tables with buttons to add and remove rows.  I set the default number of rows for each table to 8.  If I save and then open the document in Reader, everything looks fine.  When I open in Acrobat and save with Reader Extensions, it causes the following problems:

1. All table have only one row (plus header and footer.)

2. If I add rows and enter data, all added rows are lost when I save except for the one initial row.

In Form Properties > Defaults - Preserve Scripting is set to Automatic, Enforce Strict Scoping Rules is checked, and Target Version is Reader 9.0.

Does anybody have any idea what is going on here?  Here is the file: http://dl.dropbox.com/u/24270839/Daily%20Log.pdf

p.s. when I click the "add row" button it adds a row to bottom, when I click the "remove row" button, it doesn't delete the bottom row, it deletes the row that is 2nd from the top.  Why is that?

6 Replies

Avatar

Level 5

Hi,

I believe you problem with the rows being removed are because you have the repeating settings on the bindings tab set to

"Repeat Row For Each Data Item" is checked

"Min Count" is checked and set to "1"

"Initial Count" is checked and set to "8"

This would mean to me that when it is first opened it should have 8 rows, once I have saved it and reopened it I would expect it to use the data that has been entered into the form, if you have not entered any data, the it will only show "1" row as per the min count setting.

Therefore you have two setting which in my opinion are contradicting each other. if you want to make sure you always have at least "8" rows I would set them both to "8".

Onto your problem with the remove always removing the second line from the top of the table this is because you are calling this line of code

    

     subform.Table1._time.removeInstance(1);

the removeInstance call takes a parameter of a zero based index of the row you would like to remove, so as you have passed 1 this is removing the second row

row[0]

row[1] // this one is always removed

row[2]

row[3]

row[4]

row[5]

row[6]

row[7]

if you always want to remove the last one then you need to use code that uses the total number of rows - 1.

something like ( this is untested,so may not be accurate)

     var indexToRemove = subform.Table1._time.instanceManager.count - 1;

     subform.Table1._time.removeInstance( indexToRemove);

Hope this helps

Malcolm

Avatar

Level 1

Thanks for your help Malcolm

The reason I have:

"Repeat Row For Each Data Item" is checked

"Min Count" is checked and set to "1"

"Initial Count" is checked and set to "8"

is that I need the minimum number of rows to be 1 since I would only enter 1 row on days that I am off or the office is closed, etc.  Initial count is set to 8 because that is the average number of entries I would need on a given work day.

Here is the real problem:

When I do "Preview PDF" in Livecycle, it looks and acts like it should.  If I save as a regular PDF (dynamic) in Lifecycle, it looks and acts like it should.  When I open it in Acrobat, it looks and acts like it should.  When I save it with Reader Extensions, that's when everything goes to $#@!.  After I save it with Reader Extensions and open it back up in Reader, instead of 8 rows there is only 1 (besides header and footer that is.)  I can add additional rows, and fill in those added rows with data, but when I save and reopen the file all of the added rows will be gone.  Only the one original row is still there.

Why is adding Reader Extensions breaking my document?!?  This has to be a saveable document, so I have to use reader extensions.

On the positive side, I was able to solve the row removal problem with this code:

Table1._time.removeInstance(Table1._time.count - 1);

Now it removes the bottom row every time like it's supposed to.

Updated file: http://dl.dropbox.com/u/24270839/Daily%20Log.pdf

Avatar

Level 5

Hi,

Reader extensions is not breaking your form, it is working exactly as I would expect it to, this may not however be how you are expecting it to work. ( or for that matter how it should work, but I believe it is how it works)

I understand your reasoning for why you have set the form as you have with the settings

"Repeat Row For Each Data Item" is checked

"Min Count" is checked and set to "1"

"Initial Count" is checked and set to "8"

However the key to this is the setting "Repeat Row For Each Data Item".

When you first create the form and reader extend it and then open it in Acrobat/Reader there is no data and therefore the "Initial Count" setting is used and you see 8 rows in your table.

When you save the document you are creating data for the form (even if you don't enter any data) this means that for the table you are saving no data ( because you haven't entered in any values). This means that when you reopen the form after a save there is data for the form to use ( albeit the data is empty) and therefore Acrobat/Reader is using the "Min Count" setting and showing you only 1 row.

Hopefully, that explains why it is not working as you would like, now onto how to make it work as you would like.

As I understand your problem :-

- Most of the time you enter 8 rows in the tables and therefore if there is no data for the table you would like to 8 rows

- If the office is closed or you are off, you only enter 1 row

If this is correct that would mean if the table does not have any data show 8 rows, if it has data just show the data.

Therefore you could add a script to Initialise which checks the table for data and if there is no values in the table, add the rows to make 8.

this script would just have to do something like the following ( Psuedo code, will try and create the real code at some point)

if (( numberOfRows in table == 1) && ( alwaysFilliedInField in row is empty))

{

     do

     {

          add row instance;

          numberOfRows++;

     }

     while ( numberOfRows < 9);

}

Hope this helps

Malcolm.

Avatar

Level 1

Hi Malcolm

I think I understand what you're saying.  I tried opening the original document, without reader extensions, in Foxit Reader and I got the same result.  I always though that minimum would mean "the least amount you could have" not "you will have this amount no matter what" but I guess Acrobat thinks differently than I do.

"If this is correct that would mean if the table does not have any data show 8 rows, if it has data just show the data."

I think that sums it up pretty well.  The script you mentioned sounds promising, where in the document would you put that script?

I don't know much javascript, so your help is greatly apprciated. 

BTW, I tried just unchecking the "Repeat Row For Each Data Item", but the add and remove buttons wouldn't work at all when I did that.

Avatar

Level 5

Hi,

If you put this code on the initialise event of the 'time' object in you hierarchy and make sure the event is set to 'JavaScript' ( at the right of the script window title bar)

// if there is only 1 row

if ( this.instanceManager.count == 1)

{

    // if TextField1.rawValue has no content

    // I have picked TextField1 but you can choose any of the fields in a row.

    if (( this.TextField1.rawValue == "") || ( this.TextField1.rawValue == null))

    {

        // because we are here that means we only have 1 row in the table

        // and that row has no content

        // therefore create 7 more rows

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

        {

            this.instanceManager.addInstance ( true);

        }

    }

}

that should make sure that you get 8 rows if row 1 is empty.

Hope this helps

Malcolm

Avatar

Level 1

Hi Malcolm

Your script works!  I added the script, saved the file with reader extensions, opened it up in reader and there were 8 rows.  You rock!

Now there's just that little problem with data not being saved.  Even though there's 8 rows when I open it in reader, if I enter data in them and save, it still only saves the first row.

It seems that adobe is willing to add instances to the table, using your script or the button, but it is not willing to save any additional instances, whether there is data in them or not.  Maybe there's a script to count instances for a table and save those instances when you hit the save button?

Thanks for your help.