Skip to main content

Notifications

Announcements

No record found.

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

  • RE: ERROR() or TESTFIELD()

    Hi,

    My bad. Thank you for correcting me.

  • Verified answer
    RockwithNav Profile Picture
    RockwithNav 6,562 on at
    RE: ERROR() or TESTFIELD()

    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/

  • RE: ERROR() or TESTFIELD()

    Hi,

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

    Thank you for your response, anyways.

  • RE: ERROR() or TESTFIELD()

    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.

  • RE: ERROR() or TESTFIELD()

    Hi Natalie,

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

  • Verified answer
    RockwithNav Profile Picture
    RockwithNav 6,562 on at
    RE: ERROR() or TESTFIELD()

    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/

  • Verified answer
    Saurav.Dhyani Profile Picture
    Saurav.Dhyani 14,302 Super User 2025 Season 1 on at
    RE: ERROR() or TESTFIELD()

    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
    RE: ERROR() or TESTFIELD()

    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
    RE: ERROR() or TESTFIELD()

    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.

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

Daivat Vartak – Community Spotlight

We are honored to recognize Daivat Vartak as our March 2025 Community…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Tip: Become a User Group leader!

Join the ranks of valued community UG leaders

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,516 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,403 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans