Expand my Community achievements bar.

get all field-names of all fields in a form

Avatar

Level 1

Hi there,

how do I get all fields (text, textfields, radio, check, dropdown, commandButtons) in a form.

Including the access-path like Page_Name.Subform_Name.....Field_Name

I want to show them in a multiline textfield and copy and paste the path, the fieldname and the fieldtype to do documentation. There are some 450 fields in my form

So wich property of an object shows that this object is a subform, and which property shows the path to the object?

Thanks for any help

Bruno

This works fine, only the property for "is a subform" and the "Path" is missing.

2 Replies

Avatar

Level 1

I have got a solution, only the last step is missing:

  • all subforms of interest are named like this: "TFI_xxxx", e.G. "TFI_10_Info" or TFI_20_Info"
  • all textfields of interest folltow this role: "ID_xxxx", e.G. "ID_10_Info" or "ID_20_Info"

The hirarchie is this
Formular1
  + Page_1
       + TF_Head
            + TFI_10_Info             <== the subform I want to examine
                  - ID_10_Info          <== the textfield I want ot change

                 - IE_10_Info

           + anotherSubform
                  + TFI_20_Info       <== the subform I want to examine

                       - ID_20_Info   <== the texfield  I want ot change

                       - IE_20_Info

  • so there is always a structure a subform "TFI_xxxx" and a textfield "ID_xxxx", some 100 combinations .
  • I want to access programmatically all text-fields "ID_xxxx"  to change something like the rawValue.
  • I need to access the textfields without knowing the "path" (hirarchie) to it

My Problem, where I need help

  • I need to access the textfields without knowing the "path" (hirarchie) to it

I tried for 3 days now, somehow I am convienced that I am on the right track, just have not found my error

Thanks to any help!

Bruno

Hiere is my code, showing the error line ("//<<====?===== 1.st Try"), I get no object (== Null)

My Code

function allfields(Nodes){

try{

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

          var NodeName = Nodes.item(i).name;

          var NodeLength = Nodes.item(i).nodes.length;

          var NodeClass = Nodes.item(i).className;

          var myTextfeld = xfa.resolveNode("#subform.Textfeld3");

          // Subform TFI____

         If(NodeName.indexOf("TFI_") >= 0 && NodeClass == "subform"){

          // this is a subform, which has a name "TRI_xxxx"

               var InfoFieldName = NodeName.substr(3);

               var InfoDName = "Page_1.#subform." + "ID" + InfoFieldName ; //I think, I made an error here!

               // we are in a node (subform) "TRI_xxxx"

               // We can create the name of the underlying textfield (InfoDName): ID_xxxx

              

               // InfoDName shows: "Page_1.#subform.ID_10_Info" 

               xfa.resolveNode( InfoDName).rawValue="Hallo" //<<====?===== 1.st Try

               Nodes.item(i).nodes(InfoDName).rawValue="Hallo"; //<<====?===== 2.nd Try

          }

          //recursion for subforms only

          if (NodeClass == "subform"  ){

               if (NodeLength  > 0) {

                    func.allfields(Nodes.item(i).nodes);

               }

          }

     }

    } catch(err) {

     var vDebug = "";

         for (var prop in err) {

               vDebug += "property: "+ prop+ " value: ["+ err[prop]+ "]\n";

         }

         vDebug += "toString(): " + " value: [" + err.toString() + "]";

         var msg="in Level 1, dropdown\n";

         xfa.host.messageBox( msg + vDebug);

     }

}

Avatar

Level 10

Hi there,

unfortunately, you need the path of the field to access it at any times...

you can have this property with the somExpression property of any object in the form.

Without the somExpression, you have to do a loop to access the fields you want.