Tim - Potentially several issues with that version. Suggest trying the version I posted here a while back (below). Premise is to fool the system that an invalid InvoiceNo is being set by exceeding the dict length of 20 (used to be 10). Also using a built-in function to check for existing invoices. Also I don't need to reference the specific column in source file (like IMP$[2]) so that dependency is gone. Just make sure the APDivisionNo is on the Data tab and above the VendorNo.
Also the person who I wrote it for reviews the job log afterwards and not only sees the duplicate but also likes seeing the Vendor No + Invoice No as you see below. She also wanted to see Invoice Amt which I did but commented out here.
Lastly, since you do scripts you can alternately adapt same logic to Pre-Validate of InvoiceNo script where you run same CheckInvoiceHistory() function below and do SetError if true. But also make sure Left(oSession.StartProgram,2) = ""VI"".
** EDIT **
It occurred to me that since InvoiceNo is part of the key you can't run it on Pre-Validate but maybe it will work on PreWrite. Still run only when:
` Left(oSession.StartProgram,2) = ""VI"" `
This Perform below also goes on the Before Assign of Header on InvoiceNo:
** EDIT **
I made a few changes in the message that appears in the Import Job Log below.
! AP_102VISkipDuplicateInvoices.m4p
! By xkzero - Alnoor Cassim
! 07/21/2015
IF NOT(coInvcHistHdr) {
coInvcHistHdr = NEW(""AP_InvoiceHistoryHeader_Svc"",%SYS_SS)
}
InvoiceNo$ = var$ ! Field value is passed in for us as var$
retExists = coInvcHistHdr'CheckInvoiceHistory(APDivisionNo$, VendorNo$, InvoiceNo$)
IF retExists {
var$ = ""Duplicate Vendor: "" + VendorNo$ + "" Invc: "" + InvoiceNo$
! var$+= "" Amt: $"" + IMP$[n] - optionally add InvoiceAmt from source file. Change n to match column number is source file.
! Force dictionary error of length exceeded. Causes Fail entry in Import Job Log.
}
EXIT