Expand my Community achievements bar.

Reset Subform

Avatar

Level 1

So I am very new to livecycle and coding.  I have managed to figure out how to code the reset of a subform named Highlift.

This is the code I am using

<event activity="change" name="event__change">

<

script contentType="application/x-javascript">if (this.rawValue == "1") {

this.resolveNode("LHR3").rawValue = "0";

xfa.host.resetData(HighLift[0]);

}

</

script>

</

event>

Basically I have a checkbox called LHR3, that I want to reset subform highlift when it is checked.  The problem I am having is that the checkbox LHR3 won't stay checked.  When I click it, it also gets reset, along with everything else, not just the subform called highlift...what am I missing?

4 Replies

Avatar

Level 10

Hi,

It looks like you are in the XML Source tab. You don't need to script here (if fact you shouldn't as you could break your form).

If the Script Editor is not open, you can select it from the Window menu. In addition you can drag the bottom bar of the Script Editor to make it bigger/multiline.

Basically inside the if statement you are setting the value of the checkbox back to 0.

this.resolveNode("LHR3").rawValue = "0";

Comment out/delete this line and it should be okay.

There is an example here: http://www.assuredynamics.com/index.php/category/portfolio/resetting-fields/

Hope that helps,

Niall

Assure Dynamics

Avatar

Level 1

Thanks, I tried that, but it is still everything in the form, not just the subform...

Avatar

Level 10

Okay,

Well it looks like there are multiple instances of the subform, with the same name. Eg, from the [0]. You will need to give a fuller reference to the subform.

Something like:

if (this.rawValue == 1)

{

     var f1 = xfa.resolveNode("HighLift[0]").somExpression;

     xfa.host.resetData(f1);

}

This should work on the basis that the checkbox is not inside the HighLift subform.

Good luck,

Niall

Assure Dynamics