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 :
Microsoft Dynamics AX (Archived)

How to capture warning/error thrown by validatewrite() method

(0) ShareShare
ReportReport
Posted on by 405

I am trying to import  some value from excel to table ,while importing excel we are getting some warnings/errors from validatewrite() method , so we want to capture that warning/error in order to maintain log and that error/warning should not display while importing.

Thanks 

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    István Orosz Profile Picture
    2,137 on at

    Hi,

    Validating records before a CRUD operation is Best Practice, that ideally should not be skipped (although there are some rare situations where it is not needed). So first, I would suggest to check the errors/warnings you got from the validatewrite() method, analyze the root cause on database level ( table relations, keys, constrains from business logic, etc. ), try to understand why validatewrite() gives these errors.

    If you still want to catch the errors, maybe something like this:

    try

       {

           if (TABLE.validateWrite())

           {

               . . .;

           }                    

       }

       catch

       {

           . . .;

       }

    If you do not want to do anything just skip, you can use Global::exceptionTextFallThrough().

    Kind Regards,

    István

  • Gautam Profile Picture
    3,945 on at

    Hi 

    infolog.cut() can be helpful 

    Thanks 

  • Verified answer
    Chaitanya Golla Profile Picture
    17,225 on at

    Hi,

    If you check the design pattern of validateWrite method, all the required validations will be validated either with the help of switch case/series of if loops. So, you can simply make a call to infolog.infologdata() after table.validateWrite method which clears the infolog as a whole and later it need to be iterated(return type is container) to display the required messages. If you find difficult in getting the exact message, let me know will try to provide you the code.

    Refer following links:
    (Capturing Entries from the Infolog)
    www.atomicax.com/.../capturing-entries-infolog

    (Dynamics Ax Get and Remove text from the Infolog)
    www.ksaelen.be/.../dynamics-ax-get-and-remove-text-from-the-infolog

    (Get Infolog details from code)
    community.dynamics.com/.../get-infolog-details-from-code

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 > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#1
Priya_K Profile Picture

Priya_K 4

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans