Expand my Community achievements bar.

How to automatically clone or duplicate all data from a subform to another

Avatar

Level 2

We are trying to create a form that will contain 3 subform where the third one most be an exact copy of the first one. 

 

The first subform is bind to a table where only 10 lines can be print on this one because of its size.

If more than 10 lines exists, it will be printed to the next page.

The second subform contains fixed values.

The third subform most be identical to the first one.

 

Furthermore, if the first subform need overflow, it should be printed to a second page with the same layout of the first page. So the third subform of the second page must be an exact copy of the first subform of that second page too Etc.

 

This is not an interactive form, so no button will be available. It must be fully automatic.

 

Any idea how to perform this?

 

I am new in Adobe and newer in Javascript.

 

A solution I though was to create a new table where this one will contain duplicated record of the original table and use that one to bind to the first subform and have the overflow to the third subform.

But I don't know how to code that in Javascript.

 

All suggestions will be highly appreciated.

Regard

stjacqdSubformCloning.png 

8 Replies

Avatar

Level 10

The simplest way is to set all fields in those subforms to a global binding and use the same namings for fields, that should show the same data.

Avatar

Level 2

Hello Radzmar

 

Thank you for your reply.

 

What is a global binding? For now, the table in subform "Row1" of SUB_A is binded to the context table element and each cells are binded to a field of that table.

 

How the table and cells of the subform "SUB_C" should be dinded?

 

The answer of my question can be obvious but what is a global binding?

 

Regards

 

Because when I am binding the table1 and cells of the "SUB_C" to the same context table of table1 of "SUB_A". It doesn't work.

 

Avatar

Level 10

Every field and subform has a binding property which can be set under the binding tab of the object pallette.It can be none, name, global or a reference to a data node defined by a XML scheme (XSD).

radzmar_0-1664308238854.png

 

 

The binding tells the PDF viewer how to handle the entered data. Fields with the same name and a global bindung will always hold the same values.

Avatar

Level 2

Hello Radzmar

 

Thank you for the information. 

 

But how to we bind the table field to the cell if the binding is set to "Global"?

I noticed when changing the subform "SUB_C"  table1 Cell1 binding to global, it is changing the binding of the subform "SUB_A" table1 Cell1 too, So the Cell1 is no longer bind to the table field.

 

How can we bind the table.field to the cell1 then?

 

Regards

Avatar

Level 10

Cells are nothing else than fields. Just select a cell and set its binding to global. Give every cell an individual name such as Cell1_1, Cell1_2, Cell1_3 for those in the first row, Cell2_1, Cell2_2, Cell2_3 in the second row and so on … 

 

Use the same names for the cells in the other table.

Avatar

Level 2

Hello Radzmar

 

This bring another question. 

I put a subform in the cell1 of the row and add an hidden field binded to the context table field. In the initialization event of the global binded field I add the following Javascript code.

this.rawValue = this.parent.tinvoicefield1.rawValue

 

Now all the rows have the last value in the field. And the SUB_C form contains only the last value.

Now the first field has always the last value in all rows. And only the last row is displayed in the subform SUB_C 

stjacqd_0-1664387103436.png

 

Based on my understanding the Global binding is very good for single variable. But how can it work in a table where the rows value are changing?

 

Example:

Here is the context table containing 5 fields.

           Field1                    Field2         Field3 Field4 Field5

row1   TEST_CHECK1  09/23/2022  1.01     0.00    1.01

row2   TEST_CHECK2  09/23/2022  1.02     0.00    1.02

etc .

 

I have probably miss understood the approach you are describing because now the last row of the context table is duplicated to all rows in subform SUB_A, see first field, and only the first row of the subform SUB_C has the last value. Not all rows are duplicated in subform SUB_C.

I don't know what I am doing wrong.

 

Regards

 

Avatar

Level 10

I also don't know. It would help if you share your form. 

Avatar

Employee Advisor

@stjacqd The field are identified by it's object name, similar to html "id". Now there are two ways to achieve this.

  1. Write a script on each field and set the other field with the same value on exit event. You can loop through a panel since the table looks the same and just set it using a script.
  2. Create schema(XSD) map two the table which needs to have the same value to same attribute(schema need to have rows as repeatable else you will get issues)
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
    <xs:element name="Search">
        <xs:complexType>
            <xs:sequence>
              <xs:element name="Term" minOccurs="1" maxOccurs="1" type="xs:string" />
                <xs:sequence minOccurs="0" maxOccurs="unbounded">
                  <xs:element name="And" type="xs:string" />
                  <xs:element name="Term" type="xs:string" />
                </xs:sequence>
            </xs:sequence>
        </xs:complexType>
    </xs:element>
</xs:schema>


 

In the end what's less time taking and easy to scale choose that.

https://help.adobe.com/en_US/AEMForms/6.1/DesignerQuickStartTutorials/WS92d06802c76abadb6fe0558212a1...

 

https://help.adobe.com/en_US/AEMForms/6.1/DesignerQuickStartTutorials/WS92d06802c76abadb6fe0558212a1...

 

Mayank_Gandhi_0-1664436510433.png