Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Programming Microsoft Dynamics 365 Business Central - Sixth Edition

You're reading from  Programming Microsoft Dynamics 365 Business Central - Sixth Edition

Product type Book
Published in Apr 2019
Publisher Packt
ISBN-13 9781789137798
Pages 536 pages
Edition 6th Edition
Languages
Authors (3):
Marije Brummel Marije Brummel
Profile icon Marije Brummel
David Studebaker David Studebaker
Profile icon David Studebaker
Christopher D. Studebaker Christopher D. Studebaker
Profile icon Christopher D. Studebaker
View More author details

Table of Contents (12) Chapters

Preface Introduction to Business Central Tables Data Types and Fields Pages - The Interactive Interface Queries and Reports Introduction to AL Intermediate AL Advanced AL Development Tools Successful Conclusions Assessments Other Books You May Enjoy

TESTFIELD

The TESTFIELD function is widely used in standard Business Central code. With TESTFIELD, we can test a variable 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 the error message is not as informative as a careful developer would provide.

The following screenshot of the TESTFIELD function usage is from Table 18 - Customer. This code checks to make sure that the Sales Order field's Status is equal to the option value Open before allowing the value of the Sell-to Customer...

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 €14.99/month. Cancel anytime}