Expand my Community achievements bar.

Reset fields by page or subform

Avatar

Level 3

I would like any change in a pull downbox on Page 1 to reset and reload defaults on Page 2.

the first part of the question.....instead of resetting each filed one by one, is there a global script I could add to form1.Page1.region that would reset the entire page or subform to null?

This is what I'm using now

form1.Page1.region::change

this.resolveNode("Page2.LumberFramingOptions.TypicalFraming").rawValue

= null;

this.resolveNode("Page2.LumberFramingOptions.FirstFloorSystem").rawValue

= null;

this.resolveNode("Page2.LumberFramingOptions.SecondFloorSystem").rawValue

= null;

this.resolveNode("Page2.LumberFramingOptions.FirstFloorStuds").rawValue

= null;

this.resolveNode("Page2.LumberFramingOptions.SillPlate").rawValue

= null;

this.resolveNode("Page2.LumberFramingOptions.WallSheathing").rawValue

= null;

maybe something like

this.resolveNode("Page2.LumberFramingOptions.*").rawValue = null;

Hmmm...there is probably a pretty simple solution.

Thanks! PC

5 Replies

Avatar

Level 10

Hi,

Here is an example: http://assure.ly/jcHEyc

The first option (using buttons) is the best. I think the other two originated from a forum question.

Anyway, if you look at the script in the click event of the button, you will see how I set the full SOM expression of the container I want to reset and then pass this through the resetData() function.

Hope that helps,

Niall

Avatar

Level 3

Getting an error message on the link?

-pc

Noname.jpg

Avatar

Level 10

Hi,

The short link seems to work okay here. Here is the full link:

http://www.assuredynamics.com/index.php/portfolio/resetting-fields/

Maybe if you open from a browser.

Niall

Avatar

Level 3

Niall,

Wow - just getting back to this.....below is a  the script i have tied to a subform that called LumberFramingOptions as a result of the example above. Within that subform are several fields that i want to clear if the button is in the off position. A twist to this is that most of the fields in the subform have default values driven by a location pulldown. The subform is invisible unless the button is clicked on. What I may want is something tied the the visibility...that is when the subform is invisible all fields are null and that trumps the defaults that are in those fields regardless of the visibility.

Hope that makes sense....

Patrick

var f1 = this.parent.somExpression;

if (this.rawValue == "0") {

  this.resolveNode("Osr2").presence = "invisible";

  this.resolveNode("LumQuoteRequested").presence = "invisible";

  this.resolveNode("Shipfrom2").presence = "invisible";

  this.resolveNode("Page2.LumberFramingOptions").presence = "invisible";

  this.resolveNode("Osr2").rawValue = null;

  this.resolveNode("Shipfrom2").rawValue = null;

  this.resolveNode("QuoteNumLum").presence = "invisible";

  this.resolveNode("BidBy1").presence = "invisible";

  xfa.host.form1.Page2.LumberFramingOptions.resetData(f1);

}

Avatar

Level 4

Hi there,

Am I right to assume that you want the fields on the hidden subform to be null instead of their default value because you plan on exporting the data? The reason why I made that assumption is because I personally don't see any other value to nulling out hidden fields, unless it's in order to clean up the exported data....

If that's right, nulling the fields still won't remove them from the exported XML. The nodes just wouldn't have a value... i.e.

<formroot>

   <hiddensubform01>

      <nullnode01 />

      <nullnode02 />

   </hiddensubform01>

   <visiblesubform01>

      <node01>value01</node01>

      <node02>value02</node02>

   </visiblesubform01>

</formroot>

If you want to exclude the nodes for the hidden subform altogether, you should look at making hiddensubform01 a repeatable subform, with min-count = 0 and max-count=1. Then use "_hiddensubform01.setInstances(0)" to 'hide' the subform, and "_hiddensubform01.setInstances(1)" to show it. You can add this code to the initialize and change events of the radio button. Note the underscore before the subform name... you need to use the underscore when you're dealing with repeatable subforms with a min-count of 0.

If you so it this way, when you set the instance count to 0 using "_hiddensubform01.setInstances(0)", The xml will look like this:

<formroot>

   <visiblesubform01>

      <node01>value01</node01>

      <node02>value02</node02>

   </visiblesubform01>

</formroot>

.... and when you set the instance count to 1, it will look like this:

<formroot>

   <hiddensubform01>

      <nullnode01>default value 1</nullnode01>

      <nullnode02>default value 2</nullnode02>

   </hiddensubform01>

   <visiblesubform01>

      <node01>value01</node01>

      <node02>value02</node02>

   </visiblesubform01>

</formroot>

Another neat thing about this method is that using the setInstances() method resets the subform fields to their default values, so you wan't need to use resetData() anymore.

Hope that helps!

- Scott

PS. Even if you weren't indtending to export the xml, the above method is still a very clean way to 'null' out all of the fields while the subform is 'hidden' and to reset them to their default value when they are 'shown.' This way also has the benefit of not having to 'resolvenode' for every field. You just need to set the instance count on the parent repeatable subform, and this affects all child nodes visibility/rawvalues. in on go. If You need anything clarified, or if you have any questions regarding this method, just let me know.