There are cases when the user wishes to add some additional configuration to each element of the Table or Repeating group. Please follow the below steps of a basic method of doing that.
- Open "Document Definition Properties" in Document Definition editor:
- Go to the "Event Handlers" tab, choose the "After document rules are checked" and click the "Edit Script" button.
- Get the number of rows of the Table of Repeating group. Use the following code snippet:
int rowCount = Document.Field( <Table or Repeating Group full path> ).Items.Count;
-
Example of usage if the document structure is as shown below:
-
Getting the number of rows in a table:
int rowCount = Document.Field( "Document Section 1\\LineItem" ).Items.Count;
-
If it is problematic to write the path many times, you can write the script like this:
string docSec01 = "Document Section 1";
IField lineItem = Document.Field( docSec01 + "\\LineItem" );
int rowCount = lineItem.Items.Count; -
Class: IField is ABBYY FlexiCapture's own class that stores instances of document-defined fields. You can perform various operations on the instance according to the specifications. See ABBYY Online Help article for details.
-
- Example of accessing each row and column of the Table or Repeating Group if the document structure is as shown below:
- The script example (C#):
string productName = "";
string qty = "";
string unit = "";
string unitPrice = "";
string amount = ""; -
Accessing the value of an element if it is not a Table or Repeating group element:
string totalAmount = Document.Field("Document Section 1\\TotalAmount").Text;
-
Accessing the value of an element if it is a Table or Repeating group element:
IField table = Document.Field("Document Section 1\\TransactionTable");
- Getting the number of rows:
int rowCount = table.Items.Count;
- Accessing string values for column elements in each row of a Table/Repeating group:
for( int i=0 ; i<rowCount ; i++ )
{
productName = table.Items[i].Field("ProductName").Text;
qty = table.Items[i].Field("Qty").Text;
unit = table.Items[i].Field("Unit").Text;
unitPrice = table.Items[i].Field("UnitPrice").Text;
amount = table.Items[i].Field("Amount").Text;
}
- The script example (C#):
Comments
1 comment
Manish Badhan
Cannot we access the elements in Field Script section?
How can I iterate in custom action the rows and columns of the Table field?
Please sign in to leave a comment.