10 Replies Latest reply on Sep 12, 2014 10:54 AM by zeeebee

    new instance problem

    zeeebee

      hello,

       

      I have a ES4 form that I am working. I have added a row above a hidden table. This row has a button to open "show" a hidden table.

       

      When clicked the table expands. the table has many cells. One cell has buttons to add new instance or hide the table itself. The add new instance upon click is not functioning. This is what breaks.

       

      The hide table works fine.

       

      If I try the same thing but with a table that is not originally hidden then it works fine. New instances occur. I need to reduce clutter on my form so it would benefit me to have it initially be hidden but then the add new instance has to work.

       

      I use the action builder to add the javascript.

       

      any advice?

       

      thanks,

       

      -Z

        • 1. Re: new instance problem
          zeeebee Level 1

          this is the code for the add table button:

           

           

          form1.DCtable.DCtablerow1.DCtableacell1.DCtableadd::click - (JavaScript, client)

          //+ GENERATED - DO NOT EDIT (ID:F0FA29C1-D483-4F69-9B04-E7E69AD9FB64 CRC:2073942169)

          //+ Type: Action

          //+ Result2: SetPresence("$Node2","visible")

          //+ Result1: AddInstance("$Node2")

          //+ Node2: form1[0].DCtable[0]

          //+ Node1: form1[0].DCtable[0].DCtablerow1[0].DCtableacell1[0].DCtableadd[0]

          //+ Condition1: Button("$Node1","click")

          //+ ActionName: DCtableadd.click

          this.resolveNode('form1._DCtable').addInstance(1);

          if (xfa.host.version < 8) {

            xfa.form.recalculate(1);

          }

          this.resolveNode("DCtable").presence = "visible";

          //-

          • 2. Re: new instance problem
            Magus069 Level 4

            Hi,

            don't get caught by adding new instance on hidden objects. Adding new instances copies the object as it is initially created with the form.

            So if your table is initially hidden in the form and you add an instance to it, you will have to get that instance and put it visible

             

            this.resolveNode(DCtable[" + (_DCtable.count - 1).toString() + "]).presence = "visible";

            • 3. Re: new instance problem
              zeeebee Level 1

              do I add this to what I had in there or do I replace the last part with this?

              • 4. Re: new instance problem
                zeeebee Level 1

                i tried replacing it and it is still broken.

                 

                this is the key part, right?

                 

                (DCtable[" + (_DCtable.count - 1).toString() + "])

                • 5. Re: new instance problem
                  Magus069 Level 4

                  Hi,

                  Yes this line is to get the last instance of the table and then you set it to visible.

                  This code is for the purpose of adding a new instance of a Table only if the table is set to hidden by default.

                  If you are trying to add an instance of a row inside the table, this is not the right reference_syntax, you would have to addInstance to the Row1 inside the table.

                   

                  //+ GENERATED - DO NOT EDIT (ID:F0FA29C1-D483-4F69-9B04-E7E69AD9FB64 CRC:2073942169)

                  //+ Type: Action

                  //+ Result2: SetPresence("$Node2","visible")

                  //+ Result1: AddInstance("$Node2")

                  //+ Node2: form1[0].DCtable[0]

                  //+ Node1: form1[0].DCtable[0].DCtablerow1[0].DCtableacell1[0].DCtableadd[0]

                  //+ Condition1: Button("$Node1","click")

                  //+ ActionName: DCtableadd.click

                  if (this.resolveNode("form1.DCtable").presence == "visible"){

                       this.resolveNode('form1._DCtable').addInstance(1);

                       this.resolveNode(form1.DCtable[" + (_DCtable.count - 1).toString() + "]).presence = "visible";

                       if (xfa.host.version < 8) {

                             xfa.form.recalculate(1);

                       }

                  } else{

                       this.resolveNode("form1.DCtable").presence = "visible";

                  }

                  //-

                   

                  Also make sure that you have the right reference to get access to the DCtable

                  • 6. Re: new instance problem
                    zeeebee Level 1

                    hrmmmm, still broken when I click add.

                     

                    code.png

                    opentable.png

                    addtable.png

                    • 7. Re: new instance problem
                      Magus069 Level 4

                      Could you please take a screenshot of the hierarchy of the table and show it to me.

                      Identify as well which object you are trying to add an instance too.

                       

                      You might have to add an instance to the row instead of the table.

                       

                      If you are really trying to add an instance to the table you must set its maximum occurrence if there is none.

                      • 8. Re: new instance problem
                        zeeebee Level 1

                        here is the hierarchy:

                        heirarchy.png

                        here is the table:

                        DCtable.png

                         

                        here is the add button:

                        DCtableadd.png

                         

                        the same arrangement works fine if the table is initially visible. I only run into the problem when I want it to be hidden in the begining. having it be hidden will be the key to making the form manageable.

                         

                        It may end up with forty headings with forty hidden tables with the ability to add new instances of any of them.

                         

                        Also to hide half of them if they are not applicable.

                         

                        The hide works fine. I had problems with remove an instance but I found that hide works fine. Would that cause problems down the line?

                         

                        Thank you for taking the time to give it look.

                         

                        -Z

                        • 9. Re: new instance problem
                          Magus069 Level 4

                          Hi sorry about, that seems like there was some syntax error in my code, it should be working with the following

                          this.resolveNode("form1._DCtable").addInstance(1);

                          this.resolveNode("form1.DCtable[" + (_DCtable.count - 1).toString() + "]").presence = "visible";

                          if (xfa.host.version < 8) {

                                xfa.form.recalculate(1);

                          }

                          • 10. Re: new instance problem
                            zeeebee Level 1

                            It works! thank you so much!  I appreciate you for taking the time