Expand my Community achievements bar.

Guidelines for the Responsible Use of Generative AI in the Experience Cloud Community.
SOLVED

Reset button for particular pages

Avatar

Former Community Member

I would like to have a button on my 3 page form that resets pages 2 and 3 but not page 1. Can this be done?

Thanks!

Wes

1 Accepted Solution

Avatar

Correct answer by
Level 10

You should have the right path to get the somExpression...

When you start a reference_syntax with 'xfa' you must specify which property you want to access,

because you want to access you form, you must specify form as the following:

View solution in original post

26 Replies

Avatar

Level 10

Hi,

sure, you can use the resetDate methode with a comma separated list of som expressions of objects to reset-


xfa.host.resetData(xfa.form1,page2.somExpression, xfa.form.page3.somExpression);


Avatar

Level 10

Place a regular button in your form and add this script to its click event.

That's it.

Well, you will propably have to change the list of som expression, so it will fit your form design.

Avatar

Former Community Member

So if I am trying to reset ~150 fields on page 2 and 3, do I need to insert each of their SOM expressions into the script? Or is there a way to make it general to page 2 and 3?

Avatar

Level 10

If you add the SOM expression of page 2 the method will reset the data of all child elements of this page.

Avatar

Former Community Member

Okay this does not appear to be working. I may have the SOM expressions wrong for the pages. I want “SAMPLE_PG_1” and “SAMPLE_PG_2” to clear but data on “FORM” to remain.

Avatar

Former Community Member

Sorry this was supposed to be included on the last post.

FORM1.JPG

Avatar

Level 10

Hi,

the resetData() method requires strings, to resolve the node(s) to reset.

In your sample you're pointing to XFA objects so the method fails.

Add the property .somExpression which returns the SOM expression as a string, then it should work.


xfa.host.resetData(xfa.ONE.SAMPLE_PG_1.somExpression, xfa.ONE.SAMPLE_PG_2.somExpression);


Avatar

Former Community Member

“Add the property .somExpression which returns the SOM expression as a string, then it should work.”

Please excuse my ignorance but I am not sure what the above statement means. What is the “.somExpression” I should be using?

Wes

Avatar

Level 10

Hi,

somExpression is a scripting property of XFA nodes, that will return the full qualified SOM expression (as a string) of the current node.

Just try the script I posted above.

Avatar

Former Community Member

I put this script…

xfa.host.resetData(xfa.ONE.SAMPLE_PG_1.somExpression, xfa.ONE.SAMPLE_PG_2.somExpression);

into the click event and it did not work. My button is on page three and when I fill out fields on each page and press it, the field all still have data in them.

It is set as JavaScript ran at Client

Avatar

Level 10

I suggest you do it separately:

xfa.host.resetData(xfa.ONE.SAMPLE_PG_1.somExpression);

xfa.host.resetData(xfa.ONE.SAMPLE_PG_2.somExpression);

Avatar

Former Community Member

Still doesn’t work.

Thanks for your help. I’m not sure what to do

WES

Avatar

Correct answer by
Level 10

You should have the right path to get the somExpression...

When you start a reference_syntax with 'xfa' you must specify which property you want to access,

because you want to access you form, you must specify form as the following:

Avatar

Former Community Member

Excellent! That worked.

Thanks so much for your help!

I love my Community!

Wes

Avatar

Level 4

HI All!

I am wanting to do the same thing but a little different.  I have java script that hids and shows certain fields depending on the check boxes that you choose (or radio buttons)  Is there anyway to reset the page back to what it was at the beginning, all hidden fields hidden and all fields that should be showing, showing? Can that be done?  the reset doesn't make that happen?

Thanks!

Jodi


Avatar

Level 10

Hi jodi

yes it is possible if you get to reset the field's form, once that is done you can remerge the form using the following

xfa.form.remerge();

Note that remerging the form also re-initialize any data in variables back to default

Avatar

Level 4

Thanks Magus!

I will try it!  I will throw you another question Is there a way to reset specific subforms or not reset specific sub forms.  The form I am creating there is a section that is filled out by a department.  They save the form then send the rest to be filled out by a vendor.  If the vendor starts their portion and then wants to start over is there a way to reset jus their section and then use remerge and it not affect the section filled out by the department?
Thanks!

Jodi

Avatar

Level 4

Okay I was able to reset my data for only a specific subform!  Yea!!  I can get xfa.form.remerge() to work also but want to know if there is a way to only remerge the same subform that I reset the data for.  Can that be done?  Thanks for all your help!

Jodi

Avatar

Level 10

Hi Jodi, I think what you are looking for would be something like this: