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.
Solved! Go to Solution.
Views
Replies
Total Likes
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:
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.
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.
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:
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.
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.
@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
Views
Replies
Total Likes
Views
Likes
Replies