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

Announcements

No record found.

News and Announcements icon
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 124

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
    304,419 Super User 2026 Season 1 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
    124 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
    304,419 Super User 2026 Season 1 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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

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

#1
Giorgio Bonacorsi Profile Picture

Giorgio Bonacorsi 657

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 611 Super User 2026 Season 1

#3
CP04-islander Profile Picture

CP04-islander 301

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans