Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Programming Microsoft Dynamics 365 Business Central

You're reading from   Programming Microsoft Dynamics 365 Business Central Build powerful, robust, and scalable extensions customized for your business requirements

Arrow left icon
Product type Paperback
Published in Oct 2024
Publisher Packt
ISBN-13 9781803236414
Length 466 pages
Edition 7th Edition
Arrow right icon
Authors (4):
Arrow left icon
David Studebaker David Studebaker
Author Profile Icon David Studebaker
David Studebaker
Marije Brummel Marije Brummel
Author Profile Icon Marije Brummel
Marije Brummel
Natalie Karolak Natalie Karolak
Author Profile Icon Natalie Karolak
Natalie Karolak
Christopher D. Studebaker Christopher D. Studebaker
Author Profile Icon Christopher D. Studebaker
Christopher D. Studebaker
Arrow right icon
View More author details
Toc

Table of Contents (11) Chapters Close

Preface 1. Chapter 1: Introduction to Business Central 2. Chapter 2: Tables FREE CHAPTER 3. Chapter 3: Data Types and Table Fields 4. Chapter 4: Pages – The Interactive Interface 5. Chapter 5: Reports and Queries 6. Chapter 6: Introduction to AL 7. Chapter 7: Intermediate AL 8. Chapter 8: Extensibility beyond AL 9. Index 10. Other Books You May Enjoy

Validation methods

AL includes a number of utility methods that are designed to facilitate data validation or initialization. Some of these methods are as follows:

  • TestField
  • FieldError
  • Init
  • Validate

We will discuss these methods more in the following sections.

TestField method

The TestField method is widely used in standard Business Central code. With TestField, we can test a table field value and generate an error message in a single statement if the test fails. The syntax is as follows:

Record.TestField(Field[, Value]);

If Value is specified and the field does not equal that value, the process terminates with an error condition, and an error message is issued.

If no Value is specified, the field contents are checked for values of zero or blank. If the field is zero or blank, then an error message is issued.

The advantage of TestField is ease of use and consistency in code and in the message displayed. The disadvantage is that the error...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime