Error Message Processing


Do you remember when, a year and a half ago, at NAV Tech Days, you gave us feedback on the NAV Design Patterns session – saying that Journal Error Processing is not generic and decoupled enough?

Well, my colleagues Andreas Moth and Jesper Schulz from the NAV localization team at Microsoft Development Center Copenhagen, had created a framework to extract and generalize error message processing. This framework can be used across NAV. It comes with an API and new objects that you can reuse and plug into your own implementation. And part one of how to use it is described below.

Enjoy,

Bogdana Botez

NAV Design Patterns team Copenhagen

Note: This pattern describes new functionality which makes it possible to generalize the Journal Error Processing pattern.

Abstract

Missing, invalid or incomplete data is a common issue during data processing in Microsoft Dynamics NAV. This article describes how to collect all error messages during processing using the error message component and present them to the user in a unified way, which enables the user to correct the errors efficiently. By leveraging the integrated error message logging functions, you can log a message with a single line of code and present it to the user with another one-liner.

Description

This article describes how to use the Error Message component in Microsoft Dynamics NAV, which in short gives you the possibility to:

1. Link an error mesesage to the page which enables you to resolve the problem.
2. Assemble all error messages in one central view instead of having to encounter them one by one.

Validating data is a common task during data processing in Microsoft Dynamics NAV. Unfortunately, validation is often done using NAV’s integrated ERROR and TESTFIELD functions, which halt execution of the process. The user will then have to locate the invalid / missing data, correct it and reinitiate the process, possibly running into the next error, making the cycle repeat itself. This can be a very tedious, time-consuming and frustrating process. The error message component aims at improving this experience by providing a lightweight framework for error message logging and this article will explain how to leverage this functionality in your code. By doing so, all error messages are gathered during (pre-)processing and are finally presented to the user. The user then has the possibility to click on the error message, which will open the record where the invalid / missing data is located, thereby enabling the user to correct all mistakes efficiently, from one central place and in one go.

The example below comes from a Mexican localization, where the user has to export financial balances and transactions into an XML file for government audit purposes. In order to generate valid files, some mandatory data needs to be entered in the system. By leveraging the error message component, the user will be presented with the following page, if missing or invalid data was discovered:

By clicking on the error message, the user will be presented with the entity, where the invalid / missing data should be corrected / added.

Read more on the NAV Design Patterns Wiki site…

 

Best regards,

Jesper Schulz at Microsoft Development Center Copenhagen

Comments (4)

  1. Rafael Rezende says:

    Hello!

    This looks very promissing, I've created something similar with our own addon, but it's not as polished.

    Will this framework be available in the next major version? It would be great if this was included from W1 to all localizations.

    Regards,

    Rafael

  2. This framework is available for all supported versions through the latest cumulative updates. Just apply the CU and you're good to go!

    Regards,

    Jesper

  3. Rafael Rezende says:

    That's great! Thanks!

  4. I suppose everyone has this at one time or other, thing is it is only really useful for batch processing which is exactly what Nav isn't, usually.

    Occasionally Export and often Import would indeed be the usual suspects.

    But, straight away, I can think of a dozen reports that would benefit, I assume that this is (or will be real soon now) linked into the "Batch post …" routines.

    Good addition.

    But: "Available in the latest hotfix". I do wish I could instantly "Cherry-Pick" this change without the more dangerous updates, but that's really not going to be easy unless Microsoft start publishing the updates as a proper SCM database.