Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

Setting the Access of a subform

JLAFARGUE-FMiGI
Level 3
Level 3

I'm trying to set the access of a subform based on the value of a checkbox in another subform.    In the change event of the checkbox, if the rawValue == 1, then I attempt to set the access of the second subform to "protected".  If the rawValue == 0, I set the access of the second subform to "open". 

What actually happens is that the access of the second subform is unchanged.   In fact, when I try to even display the value of the access attribute of the second subform from the change event of the checkbox, the value displays a s null.  What am I doing wrong?

Here's the code that sets the access:  ('this' is the checkbox.)

if  (this.rawValue == 1) {

     parent.parent.subform2.access = "protected';

}

else {

     parent.parent.subform2.access = "open";

}

The hierarchy is this:

Mainform

     subform1

          checkbox

     subform2

          < Other Objects>

Subform2 is a repeatable subform, so when I set the access to "protected", I also want to remove all instances except the first one. 

2 Replies
Steve_L_Walker
Level 10
Level 10

First, what event are you coding against?

Second, I'd recommend removing parent references in this use case and point directly at the subform.

// form1.page1.subform1.cb::click - (JavaScript, client)

if (this.rawValue == 1) {

          form1.page1.subform2.access = "protected";

}

else {

          form1.page1.subform2.access = "open";

}

Steve

JLAFARGUE-FMiGI
Level 3
Level 3

I tried removing the parent references and specifically referencing the subform but it didnt' work.  However, I did find out how to do it from a co-worker.  Here's how.

In the checkbox change event of the checkbox  (this):

if (this.rawValue == 1) { //1

     var i = 0;

     var ref = xfa.resolveNode("MainForm.PageN.Subform[" + i + "]");

     ref.TextField.rawValue = null;                         //  repeat these two lines

     ref.TextField.access = "protected";                //   for every field you want to reset and set unavailable.

else {

     ref.TextField.access = "open";                         // repeat this line for every field to set available.

}

I haven't figured out how to travel through the hierarchy to do this, so I will have to set the rawValue and access for each individual field.