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.

Resetting all data, instances & presence properties in the form

Avatar

Level 7

I have a form that needs to be completely reset on occasion. By "reset" I mean more than just clearing data--I would like to see added instances of reoccurring table rows and subforms reset to the original number of instances, as well as, the "presence" properties reset so that hidden subforms that have been revealed, will be made hidden again.

xfa.host.resetData();     just clears the data on my form but leaves the instances and presence property as they are. I've looked at the "restoreState" property, but I'm thinking this has to be applied to to each and every item individually--probably by looping thru the entire form? I think I saw a looping script for doing that sort of thing.Is that the correct way to do this?

This form has well over 500 nodes with many that are 7 or 8 branches deep

Thanks for any advice,

Stephen

4 Replies

Avatar

Level 10

Hi,

Try including the follwoing in the reset button:

nameRepeatingTableRow.instanceManager.count = 1;

You would need to loop through the 500 nodes.

Hope that helps,

Niall

Avatar

Level 7

Hi Niall,

Your answer does give me something to think about, but doesn't solve the problem. The form has many subforms that can have multiple instances and within them there are tables with rows that can also have multiple instances. And, there are interactive "presence" properties on many of those subforms and there are interactive "presence" properties on many other non-repeating fields and subforms. In other words, its complex.

The simplest thing I can think of is to close the form without saving it and reopen it automatically. Can JavaScript do that?

Avatar

Level 7

One more thing...   I am trying to understand what a script that loops through the entire form without using the node names would look like (I imagine it uses a resolveNodes method). I could put a script in the "Initialize" event for each node that sets the default instances and presence properties for that node and then trigger that event with a loop.

Avatar

Level 10

Hi Stephen,

A couple of things...

app.execMenuItem("Close");  will close the file. The user will be prompted to save (unless they are using Reader and the form has not been Reader Enabled).

Paul has a thread with a sample for locking all fields in the Purchase Order sample (http://forums.adobe.com/message/2134982#2134982). That runs through all objects within a specified node. You may be able to adopt that for your requirements.

I suspect that because your form is complex, you may need to deal with the interactive elements separately (ie presence, repeating elements, etc.).

Paul's locking solution is a script object, which I think could be adapted.

Good luck,

Niall