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.
SOLVED

need help with a message box

Avatar

Level 6

Hello,

I need a Warning message box to pop up when I click a button that will remove the entries from a table but instead of removing the entries after I click yes or no, it removes the whole table.  I think it has something to do with the third entry, but I'm not sure.  I can't figure it out. This is what I have in the click event:

if(xfa.host.messageBox("Are you sure you want to erase all entries?", "Reset the form", 2,2) == 4){ 

    xfa.host.messageBox("All entries have been removed"); 

    xfa.resolveNode("form1.obtainedsubform.cardssubform.CARDS._Table1").setInstances(1); 

    xfa.host.resetData(); 

else { 

    xfa.host.messageBox("No entries have been removed"); 

The codes I use to reset the entries are: (rows 1 and 2 are also included, I just didn't include them here.)

this.resolveNode("Row3.smarthome").rawValue = null;

this.resolveNode("Row4.wifi").rawValue = null;

this.resolveNode("Row5.gamingsystem").rawValue = null;

this.resolveNode("Row6.gaming").rawValue = null;

this.resolveNode("Row7.networkequip").rawValue = null;

this.resolveNode("Row8.name").rawValue = null;

this.resolveNode("Row9.Make").rawValue = null;

this.resolveNode("Row10.model").rawValue = null;

this.resolveNode("Row11.serialnumber").rawValue = null;

this.resolveNode("Row12.DESCRIPTION").rawValue = null;

Any help is appreciated.

1 Accepted Solution

Avatar

Correct answer by
Level 10

The reason why all entries are reset is the existing script block before the if-expression. It nulls all fields already before you got asked what to do. Delete that script and use the following to reset just the current table instance.

if (xfa.host.messageBox("Are you sure you want to erase all entries?", "Reset the form", 2,2) === 4){

    xfa.host.messageBox("All entries have been removed");

    xfa.host.resetData(CARDS.resolveNode("Table1[" + this.parent.parent.parent.index + "]").somExpression);

}

else {

    xfa.host.messageBox("No entries have been removed");

}

View solution in original post

6 Replies

Avatar

Level 10

Hi,

We might need to see the whole form, if you are able to share post a link to it in this thread.

The line of code that looks a little odd to me is;

xfa.resolveNode("form1.obtainedsubform.cardssubform.CARDS._Table1").setInstances(1);

This looks like you are repeating the Table1 object, normally you would have one or more of the Row objects under it repeating.

Regards

Bruce

Avatar

Level 10

So is your reset button meant to set the number of equipment information blocks of questions back to 1 or just clear all the values in the form as it seems to be working as I would expect.

So, what exactly are the steps required to reproduce the problem

Regards

Bruce

Avatar

Level 6

It's meant to clear all the values if I choose yes and not clear the values if I choose no.   The red reset button in the top right corner works as it should.  It's the button labeled "remove all entries from this specific record" that is not working right.  When I click and answer no, it still removes the entries. 

Please choose Accessories and then a Accessory type and continue to fill in the form.  Click the remove entries button.  You will see that the"Type" and "Accessory Type" blocks erases when the warning block comes up.  When you click no, all entries still erases and "Accessory Type" block that was hidden does not go back to being hidden. 

Sorry for the confusion.

Avatar

Correct answer by
Level 10

The reason why all entries are reset is the existing script block before the if-expression. It nulls all fields already before you got asked what to do. Delete that script and use the following to reset just the current table instance.

if (xfa.host.messageBox("Are you sure you want to erase all entries?", "Reset the form", 2,2) === 4){

    xfa.host.messageBox("All entries have been removed");

    xfa.host.resetData(CARDS.resolveNode("Table1[" + this.parent.parent.parent.index + "]").somExpression);

}

else {

    xfa.host.messageBox("No entries have been removed");

}

Avatar

Level 6

That worked!  Thank you very much.