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
BedrockMission!

Learn more

View all

Sign in to view all badges

How to get the name of a subform in a script?

Beachbum2015
Level 3
Level 3

I have a script that I'd like to use to count how many checkboxes are checked in a particular subform.  Problem is that I have several subforms with checkboxes, and I only want to evaluate checkboxes in a certain subform.  The following script works, but again, looks at all checkboxes on the entire form.

What if statement would I need if I wanted to limit the function to only work on the subform named Employee_Info?  I just can't figure out how to specify a subform name and compare it to the subform name of each checkbox.  I hope that makes sense.

function countChk(vNode) {

          if (vNode.className === "field") {

                    if (vNode.ui.oneOfChild.className === "checkButton") {

                              if (vNode.items.nodes.length > 1) {

                                        if (vNode.value.oneOfChild.value == 1) {

                                                  nChk++ ;

                                        }

                                }

                            }

                        }

          for (var i = 0; i < vNode.nodes.length; i++) {

        countChk(vNode.nodes.item(i));

          }

}

3 Replies
Magus069
Level 10
Level 10

Hi there,

to retrieve the subform's name, simply use the attribute name

Hope this help!

Beachbum2015
Level 3
Level 3

Hi Magus069,

No luck adding the last if statement shown above.  Actually, the subform name is Door_Subform, which I changed, and it looks like the derived subform name is not matching what is specified.  I have an if statement not shown above that evaluates if nChk is < 3, then display an error message.  When I check off more than three boxes, I still get the error that not enough boxes have been checked.  So it seems that vNode.nodes.item(i).name may not be grabbing the correct attribute (subform name).

Here's the hierarchy to the subform in question.

     form1.Main.Door_Subform

Magus069
Level 10
Level 10

Hi there,

the name property would be the correct attribute to get the subform name, just by looking at the code it doesn't seem like it's doing the right thing

I am assuming that you send Main in the function countChk() which would look something like this

And you probably want to make sure you are entering the right subform so you need to keep that loop at the end of the function

but if you want to get through all the checkboxes inside that subform you must do a loop through that node to find each checkbox

I am assuming that the function would probably look something like this

Hope this help!