Community

How to access document field values in stage script

Using Flexicapture 12 for Invoices. I'm trying to get vendor name and invoice number written to batch registration parameters so that we can sort by these values in Verification Station. In the batch type, I have added a custom script stage right after Recognition and created the script below in this stage. I think everything is working except that I do not have the syntax for accessing the recognized document fields correct (vendor name and invoice).

When I run this, I always get "-1" for InvoiceNumber and "NONE" for Vendor as the batch registration parameter values, so I know the script is working, but either there are no values in those document fields or I am not using correct syntax to access those fields. Can anyone provide the correct syntax? Thanks!


if (Batch.Documents.Count > 0 && Batch.Documents[0].HasField("Document Section\\InvoiceNumber"))
{
Batch.Properties.Set("InvoiceNumber", Batch.Documents[0].Field("Document Section\\InvoiceNumber").Text);
Processing.ReportMessage ("Invoice number was added to reg. parameter");
}

else
{
Batch.Properties.Set("InvoiceNumber", "-1");
Processing.ReportWarning ("Unable to add reg. parameter");
}


if (Batch.Documents.Count > 0 && Batch.Documents[0].HasField("Document Section\\Vendor\\Name"))
{
Batch.Properties.Set("Vendor", Batch.Documents[0].Field("Document Section\\Vendor\\Name").Text);
Processing.ReportMessage ("Vendor Name was added to reg. parameter");
}

else
{
Batch.Properties.Set("Vendor", "NONE");
Processing.ReportWarning ("Unable to add reg. parameter");
}
0

Comments

5 comments

  • Avatar
    Adrian Enders

    Your "Document Section" is wrong. It's not "Document Section" in the invoice project. It is "Invoice Layout". So ...

    Batch.Documents[0].HasField("Invoice Layout\\Vendor\\Name")

     

    2
  • Avatar
    Aaron Reece

    Thanks Adrian, that was exactly the information I needed! Do you happen to know where this is located in ABBYY documentation? 

    0
  • Avatar
    Adrian Enders

    Not really. It is just visible at various spots in the project; some of the scripts and rules.

    0
  • Avatar
    Aaron Reece

    Ok, I'll keep an eye out in the project. Thanks!

    0
  • Avatar
    ElliotG

    We completed a somewhat similar project but had many documents per batch.  It's nice having the vendor name available to view in the batch view!

    0

Please sign in to leave a comment.