2 Replies Latest reply: Apr 30, 2014 7:25 AM by aufer RSS

    Can forms creation be automated ?

    aufer Community Member

      Is there a way in LiveCycle to automate the creation of Objects at Design time ? Not a Dynamic form.

       

      I need a way to create a table (or other Objects) with multiple Rows based on code !

       

      Example: I have an Excel document with multiple rows and columns & need to create a simple form

      Question                        | Answer | Comments |

      Did you like the Product | Yes, No |                  |

      On a Scale of 1 to 10     | ##         |                  |

      Other Comments            |              |                  |

       

      What I would like to do is write code that automates the whole process ( I will write the translation from the spreadsheet to code ) .

      The code should be similar to

      1. CreateATable ( "Table1", #Rows, # Columns, xPos, yPos )

       

      2. Table1.Row0.Cell1.Text = "Question" ; Row0.Cell2.Text = "Answer" ; Row0.Cell3.Text = "Comments" ;

       

      3. Table1.Row1.Cell1.Text = "Do you like the Product"

          Table1.Row1.Cell2.ObjectType = DropDown.Field ; Row1.Cell2.ObjectValues = "Yes", "No" ;

          Table1.Row1.Cell3.ObjectType = TextField

      etc.

       

      ** This code will run at Design time to allow extra formatting. Need the form to be XFA.

       

      Aubrey

        • 1. Re: Can forms creation be automated ?
          George Florentin

          I think it's possible and here is how I would do it:

           

          1. you create a table in designer, with header and 1 repeated row, minimum instance = 0;

          2. you create an XML file where you store the data that should be inserted into the table;

          3. you store the XML from step 2 in a global variable (File -> Form Properties -> Variables). The global variable has a limit of ~32.000 chars so I recommend a minified XML;

          4. you create a function (or ask me nicely ) that parses the XML and retrieves the data;

          5. you loop on that data and for each entry you add an instance of the Row in table from step 1 and populate it with data extracted from the XML.

           

          Step 5 can be called at initialize or form:ready.

          • 2. Re: Can forms creation be automated ?
            aufer Community Member

            George,

            Thanks for the answer.

            I would greatly appreciate the code that parses the XML & retreives the data.

             

            Can you send me examples for step 5.

            i.e. Code to add an instance of the Row in a table & populate it with data extracted from the XML.

             

            My preference would be to skip the XML altogether & auto generate the code for Step 5 outside of LiveCycle as I am comfortable with other coding ( specifically VBA ) which would allow me to generate code directly from a spreadsheet. ( I will post the solution with code after ).

             

            I am relatively new to LiveCycle so excuse this question.

            Does the initialize or form:ready execute during the form creation ?

            Will the text, rows, textfields etc be prebuilt & prepopulated if I were to open this PDF if Adobe Reader or some other app ?

             

            Thanks again

            Aubrey