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.

Remove instance after reopening saved form

Avatar

Level 1

Hi All,

I have a simple meeting form with add/remove row buttons for actions table. This table is hidden to start off with, and is made visible with another button.

Add Instance Code

Form1.MinutesSection.ActionsTable.Section.Row1.add_row::click - (JavaScript, client)

_Section.addInstance(1);

xfa.form.recalculate(1);

Remove Instance Code

Form1.MinutesSection.ActionsTable.Section.Row1.remove_row::click - (JavaScript, client)

// Prompt the user

var nResponse = xfa.host.messageBox("You are about to delete this Task. \n\nDo you want to continue?", "Delete row", 2, 2)

// Test the response: Yes = 4

if (nResponse == 4) {

// Invoke the Instance Manager to remove the current instance of the detail subform. required .parent.parent.parent.

_Section.removeInstance(this.parent.parent.index);

// Invoke the recalculate method to update the form calculations.

xfa.form.recalculate(1);

}

The buttons generally work great. However, if I was to add some instances to the table and then save the form to come back to to it, I'm unable to remove the instances "rows" that were added to the actions table before saving, closing and reopening the form. I can only add new rows and remove the new rows, but not the ones added prior to the reopening the form.

Is there a way to allow the user to delete previously added instances?

Thanks in advance.

I am using LiveCycle Designer ES2, Note I'm a beginner when it comes to coding.

5 Replies

Avatar

Level 10

Hi,

What you have looks ok, sometimes things get messed up if there's other repeating groups with the same names but at different levels.  Is it possible for you to upload your form to one of the file sharing sites (goolge docs, dropbox, etc) and post a link in this thread.

Regards

Bruce

Avatar

Level 1

Hi Bruce,

Here is the link to the file on Drop Box. https://www.dropbox.com/s/l96oxbhph9q5dsm/Meeting%20Minutes%20-%20Partially%20Filled.pdf?dl=0

Note, I have pre-filled some of the information to save time. The add/remove instances are for the +/- buttons next to the table rows.

Interestingly, I've just noticed that when you click "- Actions" the table is hidden. Normally it is meant to remove all the information the the table, but when "+ Actions" is pressed again, all the previous information is still there.

Thanks for taking the time to have a look at the form.

Regards,


Peter.

Avatar

Level 10

Hi Peter,

It seems the ActionsTable is reverting back to hidden, each time it is opened.  Not sure why it would do that, as you have preserve scripting changes set to automatic.  Maybe you can try setting presence (hidden/visible) in code something like;

Form1.MinutesSection.ActionsTable::initialize - (JavaScript, client)

this.presence = (_Section.count > 0) ? "visible" : "hidden";

This assumes the ActionsTable Section object now has a min count of zero, and the add button code now looks like;

if (this.resolveNode("ActionsTable").presence == "hidden") {

     this.resolveNode("ActionsTable").presence = "visible";

     ActionsTable._Section.addInstance();

}

Here's a link to a version of your form I was playing with.  https://sites.google.com/site/livecycledesignercookbooks/home/Meeting%20Minutes%20-%20Partially%20Fi...

Regards

Bruce

Avatar

Level 1

Hi Bruce,

Sorry for the late response, but I have been unavailable for a while.

I have been pondering over the form myself and ended up coming to the same conclusion you have - setting the hidden / visible options in the script in at the open instance.

The form you have changed certainly does just that, but interestingly, now it removes all the actions, instances.

I'm not versed in scripting and generally run off online resources.

I have removed the hidden option from the form all together and tested it. It still seems to loose the track of the instances.

I have another form that has the same buttons on a visible table and that form has no issues with saving / reopening.

This is as far as I have gotten for now. I wonder if the form can be corrupt and thus behaving this way.

Regards,

Peter

Avatar

Level 10

Hi Peter,

I'm not sure I follow, can you give me the exact steps to reproduce the problem.

Thanks

Bruce