Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.

Inctance management by using CheckBox => wrong index (sample file included)

Avatar

Level 3

Hello,

I use checkboxes to add new data/lines into my table.

Everything seems to work fine. My table is correctly filled but the xml data on preSubmit is totaly wrong.

You can also check it in my sample file.

My code:

function

addNewLine(CheckBox){
 

     var counter;

    

     if (CheckBox.rawValue ==

"X"){

          // add new line

          xfa.form.data.page2.MyTable._MyTable_Data.addInstance(true);

         // get last line

          counter = xfa.form.data.page2.MyTable._MyTable_Data.count - 1;

     
     // insert data into the last line

           xfa.resolveNode("xfa.form.data.page2.MyTable.MyTable_Data[" + counter + "]").LineOne.COUNTERONE.rawValue = counter;
           xfa.resolveNode("xfa.form.data.page2.MyTable.MyTable_Data[" + counter + "]").LineTwo.COUNTERTWO.rawValue = counter;
      }
}

problem2.JPG

problem1.JPG

Table filled - CORRECT

problem3.JPG

XML-Output / Attachment - WRONG!!!

<?xml version="1.0" encoding="UTF-8" ?>

- <data>

- <MYTABLE>

-      <DATA>
           <COUNTERONE>1</COUNTERONE>
          <INPUTONE />
          <COUNTERTWO />
          <INPUTTWO />
          <COUNTERTHREE />
          <INPUTTHREE />
          <COUNTERFOUR />
          <INPUTFOUR />
          <COUNTERFIVE />
          <INPUTFIVE />

</DATA>

-      <DATA>
          <COUNTERONE>2</COUNTERONE>
          <INPUTONE />
          <COUNTERTWO>1</COUNTERTWO>
          <INPUTTWO />
          <COUNTERTHREE>1</COUNTERTHREE>
          <INPUTTHREE />
          <COUNTERFOUR>1</COUNTERFOUR>
          <INPUTFOUR />
          <COUNTERFIVE>1</COUNTERFIVE>
          <INPUTFIVE />

</DATA>

-      <DATA>
           <COUNTERONE>3</COUNTERONE>
          <INPUTONE />
           <COUNTERTWO>2</COUNTERTWO>
          <INPUTTWO />
          <COUNTERTHREE>2</COUNTERTHREE>
          <INPUTTHREE />
          <COUNTERFOUR>2</COUNTERFOUR>
           <INPUTFOUR />
          <COUNTERFIVE>2</COUNTERFIVE>
           <INPUTFIVE />

</DATA>

-      <DATA>
          <COUNTERONE />
          <INPUTONE />
          <COUNTERTWO>3</COUNTERTWO>
          <INPUTTWO />
          <COUNTERTHREE>3</COUNTERTHREE>
          <INPUTTHREE />
          <COUNTERFOUR>3</COUNTERFOUR>
           <INPUTFOUR />
          <COUNTERFIVE>3</COUNTERFIVE>
          <INPUTFIVE />

     </DATA>

</MYTABLE>

</data>

can anyone help me to resolve this problem, please?

#

files:

https://acrobat.com/#d=wDb-N2wVPUcQGELLmUUNYA

https://acrobat.com/#d=dfr4FzItdBJw-rLFMgWvDQ

3 Replies

Avatar

Level 10

Here is the corrected file..

https://acrobat.com/#d=x*HgItYmjMg8ElMH6uZaUA

You do not need a section..

And then I bound your table to the repeating tag in your XML.

Thanks

Srini

Avatar

Level 3

Hello, thank you for the fast answer.

Unfortunally your uploaded file still has the problem with "wrong" xml-output IF I DO NOT USE the "input-xml". Do you have any other idea how to fix it?

Compare PDF-Data and XML-Data: (red = wrong index / counter)

problem4.jpg

Avatar

Level 3

hello again, experts

I still hope anyone could explain the strange behavior of the instance manager.

if you use my form or the one, posted by Srini, you will see, that the first data-row of the table always gets the value of the following row at its first attribute. (watch picture).

It does not matter if the table has "min 1 row" or not. How could I fix that, would anyone please explain? After all the following row-entries are placed "correctly", so it seems until I click on send and get the messed up xml-output ; (