Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.

Added Rows Do Not Save

Avatar

Level 2

Hello Experts,

I have a form that contains a dynamic entry subform for adding and removing lines using InstanceManager scripts.  The form behaves correctly when clicking on the ADD or DELETE row button.

This subform's binding is set to display with a Minimum Count of 1 and a Maximum Count of 10.

As an example of the issue, the form is filled, let's say with 2 more added lines, then SAVE, CLOSE the form is selected.  When reopening the form, the 2 added lines and their content disappears.  Only the 1st line appears with the filled data.  

Can anyone offer advice for preserving the added lines after the form is saved?

Thanks,

Eric

18 Replies

Avatar

Level 10

Make sure that under File>Form Properties>Defaults the option "Preserve scripting changes to form when saved" is selected.

Avatar

Level 2

Hi Jono,

Thanks for the quick response.

I checked my default settings and the "Preserve scripting changes to form when saved" was already set as "Manually".  The form failed with this setting, so I tried selecting "Automatically".  Still fails.

There is a check box titled, "Enforce Strict Scoping Rules in Javascript" that is currently UNCHECKED in my form.  Should this be checked?

Thanks,

Eric

Avatar

Level 10

No the "Enforce Strict Scoping Rules" is for something else.

Having the Preserve Scripting Changes set to Automatically should take care of the issue. Maybe there is a bit of script affecting the table?

Avatar

Level 2

Hi Jono,

I am currently using the following scrpts:

Add Button:

item.instanceManager.addInstance(1);

Delete Button: 

this.resolveNode("item").instanceManager.removeInstance(this.parent.index);

xfa.form.recalculate(1);

Is this the correct logic?

Thanks,

Eric

Avatar

Level 10

That should do the trick.

Sometimes I've seen problems when using checkboxes or the like and have had to script against them — like in the Initialize event of the item not showing up, but should be a different matter to what you've got.

Can you share your form?

Avatar

Level 2

Hi Jono,

I can't locate an upload button in this forum.  Should I just reply to your e-mail with the form?

Thanks,

Eric

Avatar

Level 10

Best to use acrobat.com, that way other people can take a look at it as well if I can't figure it out.

Steps to share a document...

(Thanks Srini for the instruction text!)

1. Go to URL http://Acrobat.com
2. Create an account if you don't have one.
3. Then login to the website.
4. In top left corner you will see a button called Upload.
5. Click on browse and select the file you want to upload.
6. After Uploading, mouse over on the uploaded file. Click the down arrow button and choose Share document.
7. Then you will be prompted a popup window at the lower left corner. Choose "Publish it" option.
8. In the next pop up window choose "Copy Link" option.
9. You can paste the link in the forum thread.

Avatar

Level 2

Thanks for the sharing instructions.  Here is the link to the document:

https://acrobat.com/#d=D4Zu7pvQSPc5yFw7AiVV3g

Eric

Avatar

Level 10

Weird, I have no idea why this makes a difference, but...

I played around with a couple of things that didn't work and then on a whim changed your removeInstance code on the minus button and it started working (it didn't need the this.resolveNode...etc). This shouldn't have affected anything as it's only called from the Click event of the button, I just thought I'd clean up the code a bit.

So I changed this:

this.resolveNode("item").instanceManager.removeInstance(this.parent.index);

to this:

_item.removeInstance(this.parent.index);

The underscore is a shortcut to the instanceManager (it's needed to access objects that don't have an instance yet). And you don't need the resolveNode because the button is living inside the subform it's referencing. So it's the same as writing:

item.instanceManager.removeInstance(this.parent.index);

Maybe Niall or somebody will have an idea why this worked!

Avatar

Level 2

Hi Jono,

I changed the script as you suggested but still no luck.  After saving the form with user rights invoked printing, saving, etc., then I opened the document in Acrobat Reader (which is what my clients will use to complete the form) and it still disappears the added lines after saving the data and reopening it.

Was this update successful for you in the Acrobat Reader?

Thanks,

Eric

PS:  I really appreciate all of the assistance!

Avatar

Level 10

Huh, weird, it worked for me at home in Acrobat X but not at work in Acrobat 9...didn't try it extended for Reader.

I'll try and take another look at it later today.

Avatar

Level 10

Tried a few things but can't get it to work. Not sure what the problem is, hopefully somebody else here can give it a go. And really odd that it worked ok for me in Acrobat X.

It should be remembering the added instances. I looked around for other code that might be affecting it but couldn't find anything.

The only thing I can think of is that maybe something has become bugged - sometimes objects get corrupted.

Avatar

Level 2

I hope that there are other experts in this forum who can assist me with this issue.

Thanks,

Eric

Avatar

Level 2

Hi Jono,

I am not receiving any other suggestions from the community.  Should I create a new discussion for this issue along with the link to the form?

Thanks,

Eric

Avatar

Level 10

Hi Eric,

I don't think you need to start a new thread just yet. The form is tricky as to why it is behaving that way. Let's see how we get on here.

Niall

Avatar

Level 10

Hi Eric, I think there's something bugged in your form.

I tried a few more things, I took your repeating subform and dropped it in a new document and it didn't work. But I created a new repeating subform and button in that new document and it works fine.

I put my new repeating subform into your document and it doesn't work. Which leads me to believe it's not just the subform that's the problem, there's a deeper issue going on with the form but it's able to travel with that subform as per my test above.

Niall took a look at it as well and we both noticed a couple of things:

  • Your target version is set to 7 and needs to be 8+ for the auto-save script changes (changing this didn't help though).
  • I tried a script that is supposed to restore changes manually but that didn't work. 
  • "item" is a reserved word, so I tried changing your subform name to "itemRow" but that didn't help.
  • You've used a lot of underscores in your object names which could cause problems as it is reserved for the Instance Manager. Best to stay away from punctuation in object names, using CamelCase is your best bet. I even tried a search and destroy on underscores in the xml source but didn't get anywhere with that either. But this could still possibly be causing problems.
  • There could be a problem with your data binding...but I don't know enough about that, just guessing.

And just from a performance point of view you're using a lot of resolveNode statements when you don't need to which can take a performance hit - but I doubt this has anything to do with the problem you're having.

So I think you're at a time-to-start-fresh point. You may be able to use some of the stuff that is in your existing form, but judging from the fact that the problem travelled with that subform to a new document I don't know if I'd even attempt using any of the existing stuff.

Avatar

Level 10

Maybe start off with building that repeating subform from scratch. If that doesn't work then as Jono says you will need to dig deeper.

N.

Avatar

Level 2

I will give the rebuild of the repeating subform in a new document a try.

Thanks,

Eric