Skip to main content

Basic duplicate invoice check against WFD AP Api

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);