Delete Instance of Repeating Group in Workflow Stage Script

Does anyone have a script that will delete an instance (row) of a repeating group (not table) from a stage script?

In the invoice project, recognition will sometimes find too many Order Numbers. 99% of the time the first one is correct. For this project there will only be one. My plan is to put a script in that will delete all but the first instance. I will put the script between Recognition and Verification.

I have tried a few things but it either throws an error or doesn't actually delete the row.

Thank you!

Was this article helpful?

0 out of 0 found this helpful



  • Avatar
    Edward Murphy

    Did you ever resolve?  If so, what did you do?  We're having a similar issue on a new FCI project.  There's only one Purchase Order per invoice, but FCI finds multiple incorrectly due to the behavior of the Neural Network and how it finds Purchase Orders.

  • Avatar
    Adrian Enders

    I did figure this out. The trick is to loop thru the group backwards, from last row to first in your script. I used a list, but you could just loop backward. Something like this, althought I didn't test this exact code.

    List<int> rows = new List<int>();

    for (int i = 0; i < Document.Field("Invoice Layout\\PurchaseOrder").Items.Count; i++)
    if (i > 0)
    Processing.ReportMessage( String.Format("Row {0}", i.ToString()) );

    foreach (int row in rows)
    Processing.ReportMessage(String.Format("Deleting row {0}", row.ToString()));
    Document.Field("Invoice Layout\\PurchaseOrder").Items.Delete(row);
    Processing.ReportMessage(String.Format("Row {0} deleted", row.ToString()));

Please sign in to leave a comment.