web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Suggested Answer

Validate and Validate all in Data entity import - custom validation error log

(0) ShareShare
ReportReport
Posted on by 122

I have a custom validation in my data entity. Somehow the behavior is correct when I import data(It returns a checkFailed) then throws an error. But when I edit the Invoice in line  1.0 and click "Validate" or "Validate All" the error still shows up with the original error message and the "Staging to target status" column is updated to Validated.
Presentation3.jpg

pastedimage1621585651874v1.png

What I did was I have a custom code in validateWrite in my data entity and I used checkFailed. Any tips on how to properly log or remove error message?

Thanks in advance

I have the same question (0)
  • Suggested answer
    André Arnaud de Calavon Profile Picture
    301,037 Super User 2025 Season 2 on at

    Hi xppdev,

    Can you tell if the error on the screenshot is a default error or if this is related to your custom validation? I assume this is your custom validation. In that case, probably it will also find the new imported target record and will consider this as existing invoice number. However, I don't know what exact x++ coding you used for your validation.

  • xppdev Profile Picture
    122 on at

    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

  • Suggested answer
    André Arnaud de Calavon Profile Picture
    301,037 Super User 2025 Season 2 on at

    Hi xppdev,

    The validation logic is executing the field validations only; not the validateWrite. You add the CustomTable call to the validateField method. Then it should be considered.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Martin Dráb Profile Picture

Martin Dráb 544 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 450 Super User 2025 Season 2

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 250 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans