Expand my Community achievements bar.

How to add subforms by Scripting

Avatar

Level 2

Hello All,

I am trying to create an item subform based on the data in the XML, the item subform is reapeatable.  I am using the code below to initiate the subform in the initialise event and fields to be displayed are under the ItemBody Subform.

var List = ref(xfa.datasets.data.Invoice.InvoiceDetail.ListOfInvoiceItemDetail)

  for i=0 upto List.nodes.length step 1 do

      

          _ItemBody.addInstance(1)

        xfa.form.recalculate(1)

endfor

Can anyone suggest the steps to create the subforms dynamically via scripting(Using addinstance).

Regards,

Harry

2 Replies

Avatar

Level 10

Hi,

In my experience you do not need to use script at all for this functionality.

Just make sure that the repeating object is set to repeat in the Object > Binding palette. Then when the data is imported the form will render the right amount of instances to suit the data being imported.

Does that make sense?

Niall

Avatar

Level 2

Hi Niall,

I am trying to repeat the subform by duplicating it in the next page. All the header data is visible from the xml but the items appear only in the first subform, i was hoping to write a script to populate the subforms programmatically.

Regards,

Harry