The screenshot is related to my custom validation.
Below is the code I used for the validation. The data entity is a duplicate of VendInvoiceJournalLineEntity.
public boolean validateWrite()
{
boolean isValid = true;
isValid = LedgerJournalEntityBase::isWorkflowDocumentEditable(this.JournalBatchNumber);
if (isValid && this.AccountType == LedgerJournalACType::Ledger && this.OffsetAccountDisplayValue != '')
{
isValid = checkFailed(strFmt("@AccountsPayable:InvoiceJournalLineEntityOffsetAccountError", "@SYS11162", "@SYS27730", "@SYS13356"));
}
if (isValid)
{
isValid = super();
}
//custom code start
if (isValid)
{
isValid = CustomTable::findDuplicateInvoice(this.Invoice, this.LineNumber);
}
//custom code end
return isValid;
}Below code is the code I used for my CustomTable.
static public boolean findDuplicateInvoice(InvoiceId _invoiceId, Real _lineNumber)
{
boolean ret = true;
CustomTable customTable;
if(_invoiceId != null)
{
select firstonly customTable
where customTable.InvoiceNo == _invoiceId;
ret = customTable.InvoiceNo != _invoiceId ? true : checkFailed(strFmt("xxx Line %1 – Invoice %2 is already existing in custom table", _lineNumber, _invoiceId));
}
return ret;
}
I'm expecting that when you click Validate/Validate all. The error message will also be updated. For example, the file that I imported has an Invoice "123456" but it is already existing in my custom table so the behavior is correct it returns "xxx Line %1 – Invoice %2 is already existing in custom table" in the View Staging data but when I update the Invoice to a non existing number then click validate/validate all. The error message does not update.
Thank you