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

ERROR() or TESTFIELD()

(0) ShareShare
ReportReport
Posted on by 5,596

Hi all,

Just wanted to ask your views on ERROR() and TESTFIELD().

I feel that TESTFIELD() error message is not that user friendly. So I prefer to use ERROR() more than TESTFIELD(). Your views?

*This post is locked for comments

I have the same question (0)
  • Verified answer
    Community Member Profile Picture
    on at

    Hi,

    This depends on the various programming conditions & related output.

    Testfield would give you common message across NAV, where as Error message text would depends on the programmer, however would be more meaningful to end user.

    If you feel, Error is more helpful, you can certainly go ahead and define your own message.

    Refers following link for more details.

    www.archerpoint.com/.../pierrot-le-fou-testfield-and-error-messages-microsoft-dynamics-nav

    Hope this helps.

  • Verified answer
    Natalie Karolak - the BC Docs Librarian Profile Picture
    1,955 on at

    You can use FIELDERROR instead.

    It combines the automatic output of the affected record, with an individual text before it.

    Example (related to TESTFIELD): <Your field> "should be bigger than field X" <in table Y, primary key fields>.

  • Verified answer
    Saurav.Dhyani Profile Picture
    14,419 User Group Leader on at

    Hi,

    It actually depends on situation -

    1. Testfield will give you an error message with the Primary key of the Table.

    2. TestField is not only used to check value is there or not, it also allow you to check a specified value like -

    TestField(MyInt,5) if not 5 you get an error.

    3. With Error you can write your on Error Messages but that depends on how different users will interpret what you write in Error Message. 

    4. When you use error you need to additional line of code to Test the condition, not measure but it adds a load to run that condition.

    To Summarize, Use Error when you actually think it make sense like Sales Line where new users will not know what is line no and all, but what about Microsoft Testfields..

    Lol yes you cannot remove all of those for sure but for setup / Master tables or Table does not have Composite key, i think TestField is the best option  

    Hope i am making sense.

  • Verified answer
    RockwithNav Profile Picture
    8,959 Super User 2026 Season 1 on at

    Hey Nareshwar,

    There's a very clear difference between TESTFIELD  and ERROR, TESTFIELD you can apply only to Record.Fields but Error you can use it anytime anywhere.

    Every time for ERROR you have to give your custom Message whereas TESTFIELD will handle itself.

    If you will ask from Performance and code optimization point of view i will recommend to use TESTFIELD on most of the cases wherever you can.  

    Thanks

    https://rockwithnav.wordpress.com/

  • Nareshwar Raju Vaneshwar Profile Picture
    5,596 on at

    Hi Natalie,

    Thank you so much for the reply. Will try using FIELDERROR();

  • Nareshwar Raju Vaneshwar Profile Picture
    5,596 on at

    Hi Saurav,

    Thank you for valubale input. I always try to implement error messages through TESTFIELDS() rather ERROR() until my the end users complain about the user-friendliness.

    Kudos to you.

  • Nareshwar Raju Vaneshwar Profile Picture
    5,596 on at

    Hi,

    As Saurav explained, you can use TESTFIELD() for your custom variables such as, TESTFIELD(MyInt,5).

    Thank you for your response, anyways.

  • Verified answer
    RockwithNav Profile Picture
    8,959 Super User 2026 Season 1 on at

    Hey Nareshwar,

    You cant use TESTFIELD for your custom variables. It's only for Record.FIELD.

    Check out this link.

    https://msdn.microsoft.com/en-us/library/dd301274.aspx

    Hope this helps.

    Thanks

    Blog https://rockwithnav.wordpress.com/

  • Nareshwar Raju Vaneshwar Profile Picture
    5,596 on at

    Hi,

    My bad. Thank you for correcting me.

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

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans