title: Summarize table using C# and JScript
body: <p>I've written code in C# to summarize values of <code>InvoiceTable</code> and move those summarized values to to <code>GroupTable</code> in Abbyy FlexiCapture. The Software is comparatively new and does not show any error when I run it. </p>
  
  <p>There are two sets of code to be written:</p>
  
  <ol>
  <li>In TechField.</li>
  <li>In EventHandlers.</li>
  </ol>
  
  <p><code>InvoiceTable</code> consists of:</p>
  
  <ul>
  <li>TariffNumber</li>
  <li>ShipQty</li>
  <li>Amount</li>
  <li>COO</li>
  </ul>
  
  <p><code>GroupTable</code> consists of:</p>
  
  <ul>
  <li>HSCode</li>
  <li>Qty</li>
  <li>Amt</li>
  <li>CountryOO</li>
  </ul>
  
  <p>EventHandlers code is as follows (C#):</p>
  
  <pre><code>if (ChangedStates.Has(7)) {
      int currentRow = 0;
      int i;
      for (i = 0; i &lt; Document.Field("Invoice2\\InvoiceTable").Items.Count; i++) {
          if (Document.Field("Invoice2\\InvoiceTable").Cell("TariffNumber", i).Value == "") {
              Document.Field("Invoice2\\GroupTable").Cell("HSCode", currentRow).Value = Document.Field("Invoice2\\InvoiceTable").Cell("TariffNumber", i).Value;
              Document.Field("Invoice2\\GroupTable").Cell("Amt", currentRow).Value = Document.Field("Invoice2\\InvoiceTable").Cell("Amount", i).Value;
              Document.Field("Invoice2\\GroupTable").Cell("Qty", currentRow).Value = Document.Field("Invoice2\\InvoiceTable").Cell("ShipQty", i).Value;
              currentRow++;
          }
      }
  }
  </code></pre>
  
  <p>TechField is as follows (JScript):</p>
  
  <pre><code>for (i = 0; i &lt; Field("ShipQty").Items.Count - 1; i++) {
      for (j = i + 1; j &lt; Field("ShipQty").Items.Count; j++) {
          // if same new items are found
          if (Field("TariffNumber").Items(i).Value == Field("TariffNumber").Items(j).Value &amp;&amp; Field("CoO").Items(i).Value == Field("CoO").Items(j).Value)
          {
              // summarise quantities
              Field("ShipQty").Items(i).Value = parseInt(Field("ShipQty").Items(i).Value) + parseInt(Field("ShipQty").Items(j).Value);
  
              // and weights
              Field("Amount").Items(i).Value = parseFloat(Field("Amount").Items(i).Value) + parseFloat(Field("Amount").Items(j).Value);
          }
      }
  }
  </code></pre>
  
  <p>Condition:</p>
  
  <p>In the <code>InvoiceTable</code>, where ever <code>TariffNumber</code> and <code>COO</code> are equal, values of <code>ShipQty</code> and Amount should be summarized and put into <code>GroupTable</code>.</p>
  
  <p>The code does not show any errors but does not give the output as well. Would be great if anyone of you can help me out on this.</p>