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.

Script for Undo Button?

Avatar

Level 1

Hello,

I am new to LiveCycle and I'm looking for a way to create a Undo button in a form.  Can anyone help? 

Thanks

5 Replies

Avatar

Level 9

Hi,

You can drag a button from the ObjectPallete and place the following script in the click event of the button.

xfa.host.resetData();

Or you can directly drag the Reset button from the ObjectPallete.

RestButton.JPG

Thanks.

Bibhu.

Avatar

Level 10

Hi,

This would be a real "nice to have", but I don't think that it is possible.

For starters, Undo/Redo are not available on the Edit menu for Dynamic XML Forms. Undo/Redo are available in Static PDF Forms and AcroForms.

You can script a button to access some menu items, using app.execMenuItem();. However "Undo" and "Redo" are not exposed/available (presumably a security restriction).

If your form is saved as a Static PDF Form, then at least the users can still press Control+Z or click Undo from the Edit menu.

Hope that helps,

Niall

Assure Dynamics

Avatar

Level 10

Hi, It probably depends on how complicated your form is but you can save the form data using "$record.saveXML()", this will return a string containing the form data as XML, this could be saved in a form variable (or series of form variables if you want multiple undos).  Then when you want to undo you can do a $record.loadXML({the string you saved}).  But after that you will have to do a xfa.form.remerge() and that can be a bit of a killer as any script run in initialising, docReady, layoutReady, etc will need to be reexecuted.

So depends on how complicated you form is.  Also wont help undoing adding attachments or pictures if you have any of those.

Good luck,

Bruce

Avatar

Level 1

Thanks for all the suggestions everyone.  As it turns out, undoing adding images into a dynamic expanding table is exactly what I am trying to achive.  Reseting the portion of the form isn't giving me the results I want, it just removes the image from the image field and doesn't remove row.  I have a button that will manually remove rows but the form freaks out when I remove or set the presence to hidden for the last remaining row.  An extra blank page appears and the form scrolls back and forth between it. All the other fields become frozen as well.  I guess I'll have to play around with this a bit or just leave the last image field visible and blank.

Avatar

Level 10

Hi,

In that case have a look at this example (in particular Table 5 which uses tables and Table 6 which uses subforms): http://assure.ly/gBJYj9

The reset button demonstrates how you can target specific objects to be reset (if you don't want to reset the whole form). In addition it shows how you can set up a loop to remove rows until you are back to one row.

Hope that helps,

Niall