Expand my Community achievements bar.

SOLVED

Resetting a specific page on a multipage form.

Avatar

Level 2

Hello.  I'm using AEM Forms Designer 6.5.  I have a multi-page form (16 pages).  If I were to reset all the fields in page13 only, can this be done using Action Builder?  I've looked at the options in Action Builder, the only choice I have is to Reset the entire form (all 16 pages).  I don't want to use that.  If it has to be scripted, how would I go about doing that?  For instance, I created a button on my Page 13 that says Reset This Page Only.  If this button is clicked, I want to reset Page 13 only.  Any assistance would be greatly appreciated.

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Hi @neohavix 

Yes, you can use a script to reset only the fields on page 13 of your AEM Forms Designer form. Here's an example of how you can do this:

  1. Create a button on page 13 and name it "Reset This Page Only" or something similar.
var resetFields = xfa.layout.pageContent(page13).descendants;

for (var i = 0; i < resetFields.length; i++) {
  if (resetFields[i].type !== "subform") {
    resetFields[i].rawValue = "";
  }
}

This script uses the xfa.layout.pageContent method to retrieve all the fields on page 13, and then loops through them to reset their values to blank. The if statement checks if the current field is a subform, as you may not want to reset the fields within a subform.

  1. Click "OK" to close the script editor.
  2. Click "OK" again to close the "Action Builder" dialog box.

Now, when the "Reset This Page Only" button is clicked on page 13, all the fields on that page (except for those within subforms) will be reset to blank values.

View solution in original post

2 Replies

Avatar

Correct answer by
Community Advisor

Hi @neohavix 

Yes, you can use a script to reset only the fields on page 13 of your AEM Forms Designer form. Here's an example of how you can do this:

  1. Create a button on page 13 and name it "Reset This Page Only" or something similar.
var resetFields = xfa.layout.pageContent(page13).descendants;

for (var i = 0; i < resetFields.length; i++) {
  if (resetFields[i].type !== "subform") {
    resetFields[i].rawValue = "";
  }
}

This script uses the xfa.layout.pageContent method to retrieve all the fields on page 13, and then loops through them to reset their values to blank. The if statement checks if the current field is a subform, as you may not want to reset the fields within a subform.

  1. Click "OK" to close the script editor.
  2. Click "OK" again to close the "Action Builder" dialog box.

Now, when the "Reset This Page Only" button is clicked on page 13, all the fields on that page (except for those within subforms) will be reset to blank values.

Avatar

Level 2

@partyush thank you for the script.  However, I'm a bit confused on terminology.  You mention script editor and Action Builder at the same time.  In AEM, I know Action Builder and the Script events, i.e., from the dropdown I can choose from the list different types of events I want to script like exit, validate, calculate, etc.  I'm used to Action Builder with event scripts but not with script editor and Action Builder.

This is what I tried.  I copied the code as is with the following changes.  I used the Events>Click.  Changed Page13 to Page1.  This is the error result:

Exception in line 2 of function top_level, script XFA:form1[0]:Page1[0]:ResetThisPageOnly[0]:click

GeneralError: Operation failed.
XFAObject.pageContent:2:XFA:form1[0]:Page1[0]:ResetThisPageOnly[0]:click
Argument mismatch in property or function argument