Basic duplicate invoice check against WFD AP Api

Created by Jeremy Burgess, Modified on Mon, 15 Aug, 2022 at 8:54 AM by Jeremy Burgess

Symptoms

You cant to implement a simple duplicate invoice check from within ABBYY FlexiCapture, calling the 

Cause

n/a

Resolution

Create a rule on the invoice number field. Ensure that the rule also includes the Bu ID and Vendor ID fields.

using System;
using WFD.AbbyyRules.Standard;
using WFD.AbbyyRules.Standard.Helpers;
using WFD.AbbyyRules.Standard.Services;

var apiService = FCTools.ScriptContext.GenerateDefaultApiService();

int buId = -1;
if (int.TryParse(Context.Field("BUId").Text, out buId) == false)
{
    Context.ErrorMessage = "BU not selected";
    Context.CheckSucceeded = false;
    return;
}

int supplierId = -1;
if (int.TryParse(Context.Field("VendorId").Text, out supplierId) == false)
{
    Context.ErrorMessage = "Vendor not selected";
    Context.CheckSucceeded = false;
    return;
}

Context.ErrorMessage = apiService.CheckInvoiceExists(buId, supplierId, Context.Field("InvoiceNumber").Text);
Context.CheckSucceeded = String.IsNullOrEmpty(Context.ErrorMessage);


Alternatively, use the logic within the standard rules DLL:

using WFD.AbbyyRules.Standard.FieldRules;

InvoiceData.DoesInvoiceNumberExist(Context, FCTools.ScriptContext);

Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select at least one of the reasons
CAPTCHA verification is required.

Feedback sent

We appreciate your effort and will try to fix the article