19 Replies Latest reply on May 25, 2009 7:04 AM by pguerett

    Dynamic Forms with Bindings

    ebb01983

      Hello all,  need some help,

       

       

      I have an odbc connection to an excel file and I have made a data connection to the excel document. I can see my two fields in my dataconnection.

      What I want to do is for each row in my excel table I want to output its counterpart field and value on the pdf document. but I am having trouble doing this. I can only output the first row. I have made a subform and set it to minimum 1 instance. Please see my image below for a better explanation, I would really appreciate if somebody could explain to me how I can do this, or even better give me an quick example file.

       

      http://docs.google.com/Doc?id=dcj7tdvs_4fwbq65qf

        • 1. Re: Dynamic Forms with Bindings
          pguerett Level 6

          You can only get 1 row at a time. There is no concept of a record set where you can work with a local copy of the data. So what you are seeing is the 1st record being returned. You can use a SQL statement to get the specific records you want. You will have to get a count of the number of records then create a loop that will get each record one by one and update your local fields. This will involve some coding in the form .....do you understand code? If not I would not recommend going this route.

           

          Paul

          • 2. Re: Dynamic Forms with Bindings
            ebb01983 Level 1

            yes i appreciate i would need some kind of loop, however I am no expect in creating code myself, if i had an example on the other hand i am more then capable of modifying for my needs. any chance for some sample code/pdf document.

             

            I have also looked at this page: http://forms.stefcameron.com/2006/10/12/displaying-all-records-from-an-odbc-data-connectio n/ but i cant seem to  get it to work with excel for some reason, i get an odbc error.

            • 3. Re: Dynamic Forms with Bindings
              pguerett Level 6

              That is an excellent example showing everything that needs to be done. If you are using Acrobat hit Ctrl-J to get the Java console where any runtime errors will be reported.There may be a clue there.

               

              Paul

              • 4. Re: Dynamic Forms with Bindings
                ebb01983 Level 1

                Hello,

                 

                I have followed through this tutorial and have it half working, it was not working before because I needed to add the following line to my XML:

                 

                <?originalXFAVersion http://www.xfa.org/schema/xfa-template/2.4/?>

                 

                now my problem is different, I have the following situation:

                 

                http://docs.google.com/Doc?id=dcj7tdvs_6hpdrkqds

                 

                 

                I am trying to have 4 fixed rows in my document and anything after that gets added on, but as you can see, I have 4 empty rows followed by the rest of my entries. I need to have always 4 rows on the page. I have set repeat subform for each data item and set the minmum count to 4.

                What has gone wrong here?

                • 5. Re: Dynamic Forms with Bindings
                  pguerett Level 6

                  Did you initialize the table with 4 instances of the subform? What if the table started without any rows ....it looks like the code is adding the rows for you.

                   

                  Paul

                  • 6. Re: Dynamic Forms with Bindings
                    ebb01983 Level 1

                    I have set Minimum instance to 4,

                     

                    But now I am going to try a new route because I am finding it hard to get help on this subject. Please I hope somebody can help me with the code. I am very new to all this and now I am stuck for nearly 1 week on this part.

                     

                    Please see this image below:

                    http://docs.google.com/Doc?id=dcj7tdvs_10g246nvfz

                     

                    The first 4 rows are manually binded, this means the first 4 rows are always fixed on my form. which is what i want. I called this subform FixedSF.

                     

                    The next 6 rows are automatically generated, it looks up a table from an excel document and uses the following code, i called this ExpandingSF.

                    http://docs.google.com/Doc?id=dcj7tdvs_8vg93q7gw&hl=en_GB

                     

                    Now my problem, i wish to alter this code, so that instead of starting from instance 0, it starts from instance 4 (or node 4?). So basically my form will have number 1 to 4 then number 5 to 6 can somebody please please please help me alter the code, i tried everything, this is not my code and I am no expert!

                    • 7. Re: Dynamic Forms with Bindings
                      pguerett Level 6

                      This is difficult without having the form and the data. Can you post the form and data and I will have a look when I get a chance.

                       

                      Paul

                      • 8. Re: Dynamic Forms with Bindings
                        ebb01983 Level 1

                        Hello, I appreciate your help, please find attached my documents i have been testing with.

                         

                        I really hope you can help

                         

                        You need to make an odbc connection for the excel file.

                        • 9. Re: Dynamic Forms with Bindings
                          ebb01983 Level 1

                          excel file failed to attach, so i have changed the extension to txt, please change back to .xls

                          • 10. Re: Dynamic Forms with Bindings
                            ebb01983 Level 1

                            Hi Pguerett,

                             

                            I was hoping maybe you had a chance to look at this and perhaps help me out (or anyone else for that matter)

                             

                            Please anyone I would really appreciate any help on this.

                             

                            Many Thanks

                            • 11. Re: Dynamic Forms with Bindings
                              pguerett Level 6

                              screen1.jpg

                              I am confused .....this is what I am getting ....is this not what you described?

                               

                              Paul

                              • 12. Re: Dynamic Forms with Bindings
                                ebb01983 Level 1

                                Hi Paul, Thats the same thing i get - i dont want that.

                                 

                                I want the first 4 rows to be fixed on the page. (Because the form will not look very pleasing if there is less then 4 entries, so i must have 4 rows, even if some are empty) 

                                 

                                So as an example,  if I have 2 entries in my EXCEL file, then i want to see the following on my pdf form:

                                 

                                -START OF TABLE-

                                Billy 1

                                Michael 2

                                *empty box* *empty box*

                                *empty box* *empty box*

                                -END OF TABLE-

                                 

                                if there are  0 entries in my EXCEL file, then i want to see the following on my pdf form:

                                 

                                -START OF TABLE-

                                *empty box* *empty box*

                                *empty box* *empty box*

                                *empty box* *empty box*

                                *empty box* *empty box*

                                -END OF TABLE-

                                 

                                if i have 6 entries in my EXCEL file, then i want to see the following on my pdf form:

                                 

                                -START OF TABLE-

                                Billy 1

                                Michael 2

                                Tommy 3

                                Chris 4

                                John 5

                                Jimmy 6

                                -END OF TABLE-

                                 

                                etc

                                 

                                I hope this clears up what I am trying to achieve.

                                • 13. Re: Dynamic Forms with Bindings
                                  pguerett Level 6

                                  Ok so do not have two tables.... (delete the Fixed SF table) you only need 1. Then click on the Expanding SF subform, on the Object palette under the Binding tab, set the Initial count to 4. You can also set the min count to 4 (if yougive the user the ability to remove rows dynaically). These settings are applied at run time so your design will not reflect this.

                                   

                                  Paul

                                  • 14. Re: Dynamic Forms with Bindings
                                    ebb01983 Level 1

                                    Hi Paul,

                                     

                                    I understood what you said, I removed the FixedSF form and set the intial count on the Expanding SF form to 4. In fact this is exactly how had it setup before I asked for help. Here are the results:

                                     

                                    http://docs.google.com/Doc?id=dcj7tdvs_12gfsxv3hr

                                     

                                    Note: this is slightly different from your screen, the first 4 (empty rows) are actually instances off the ExpandingSF form, (you can see this because it says just "Name" instead of "Name1" "Name2" "Name3" "Name4".

                                     

                                    So as you can see, setting the initial count only adds 4 empty rows into the page and then the code seems to kick in to create thedynamic rows, what can I do to fix this?

                                    • 15. Re: Dynamic Forms with Bindings
                                      pguerett Level 6

                                      I added a test in your script to see if we were in one of the 1st four rows, if so we fill out what we have, if not then we add a subform and populate that.

                                       

                                      See the attached file. You will have to update the datasources to point to your DB and not mine

                                       

                                      Paul

                                      1 person found this helpful
                                      • 16. Re: Dynamic Forms with Bindings
                                        ebb01983 Level 1

                                        Paul, Thank you so much.....really God bless you.

                                         

                                         

                                        Now the last thing, where did you make the change can you post an extract so I can see and maybe you can explain a little bit?. I wish to re-use this code for another form.

                                        • 17. Re: Dynamic Forms with Bindings
                                          pguerett Level 6

                                          On line 57 of the script I added this code:

                                           

                                           

                                           

                                           

                                           

                                           

                                           

                                           

                                           

                                           

                                          // Loop through each record and make a new instance of MovieSF for each one

                                          //

                                          //initialize a counter

                                          var

                                           

                                          j = 0;

                                          while

                                           

                                          (!oDB.isEOF())

                                          {

                                           

                                               //Get a reference to exist subforms (o indexed)

                                           

                                               if (j <= 3){

                                           

                                                    var oNewPerson = xfa.resolveNode("ExpandingSF[" + j + "]");

                                               }

                                          else {

                                           

                                                    // Create a new instance and get a reference to it.

                                           

                                                    var oNewPerson = _ExpandingSF.addInstance(0);

                                               }

                                           

                                               //increment counter

                                               j

                                          = j + 1;

                                          .........

                                          Paul

                                          • 18. Re: Dynamic Forms with Bindings
                                            ebb01983 Level 1

                                            Thanks alot,

                                             

                                            Its working and now i need some help again *suprise*

                                             

                                            I want to include two subforms, but the code i used, only puts data into the first subform, so i copy+pasted the code (then changed the variable names and it works.......but only in livecycle, please see the picture:

                                             

                                            http://docs.google.com/View?id=dcj7tdvs_15c7s72gcg

                                             

                                            When I open it in acrobat i get the following errors:

                                             

                                            Acrobat JavaScript Debugger Functions Version 7.0
                                            Acrobat Database Connectivity Built-in Functions Version 8.0
                                            Acrobat EScript Built-in Functions Version 8.0
                                            Acrobat Annotations / Collaboration Built-in Functions Version 8.0
                                            Acrobat Annotations / Collaboration Built-in Wizard Functions Version 8.0
                                            Acrobat Multimedia Version 8.0
                                            Acrobat SOAP 8.0

                                            GeneralError: Operation failed.
                                            XFAObject.setAttribute:25:XFA:form1[0]:initialize
                                            This operation violates your permissions configuration.


                                            GeneralError: Operation failed.
                                            XFAObject.setAttribute:25:XFA:form1[0]:initialize
                                            This operation violates your permissions configuration.

                                             

                                            The Code I used for my livecycle file is as follows

                                            http://docs.google.com/View?id=dcj7tdvs_149fhfz5g7

                                             

                                            I can also mention i added a new dataconnection called "dataconnection2" is this neccessary i think it is conflicting with "dataconnection"

                                             

                                            Basically how can the code by adjusted to support 1 or more subform?

                                            • 19. Re: Dynamic Forms with Bindings
                                              pguerett Level 6

                                              There are two isses that I see.

                                               

                                              1. The error that indicates that you are violating permissions..... There was a change made to Acrobat 8 that would not allow you to modify the SourcSet dom programmatically once th eform is rendered. This is what you are running into. If you go back to the post where I mention a blog entry by Stefan Cameron he talks in depth about this issue and how to get around it by cloning the SourceSet dom. As an alternative you could set the traget version of your form to 7.0.5 and that shoudl allow you to modify the sourceset dom.

                                               

                                              2. The ability to address multiple dynamic subforms. This is done by using an occurance number on the subform that is repeating. So if I had a Table with repeating row subforms and I wanted to update a field called Name in 3rd row you would use the following syntax:

                                               

                                              Table.Row[3].Name.rawValue.

                                               

                                              This is fine but normally the occurance is contained with a variable so you CANNOT do this:

                                               

                                              Table.Row[varName].rawValue

                                               

                                              So you must use the format like this:

                                               

                                              xfa.resolveNode("Table.Row[" + varName + "]").Name.rawValue

                                               

                                              The resolveNode accepts a string and not an expression so you can concatinate (as I have done) the expression for wat you need.

                                               

                                              Hope that helps

                                               

                                              Paul