Hello guys, Let’s have a look about TESTFIELD. Most probably you may used this function when you do the coding. As I learn we can use TESTFIELD function for Tests whether the contents of a field match a given value or if any mandatory field there you can use this function.

Let’s have a quick look about how it looks like. Record.TESTFIELD(Field, [Value]) .Testfiled you can use with the record type variable or with a record. Let’s take a simple example, In the item table we have a field called Gross Weight ,When the particular item uses in sales order we need to check whether it matches with the given value in Sales Line. For this instance you can use TESTFIELD function. Let me take another example. User wants to mandory Gross Weight when the creation of Item. for this instance also you can use TESTFIELD function.

Here is a sample code for your better understanding.

This example shows how to use the TESTFIELD function without the Value parameter. This example requires that you create the following variable in the C/AL Globals window.

Variable nameDataTypeSubtype
CustomerRecRecordCustomer

CustomerRec.”No.” := ”;
CustomerRec.TESTFIELD(“No.”)

The following error message is displayed:
You must specify No. in Customer No.=”.

This example shows how to use the TESTFIELD function with the Value parameter. This example requires that you create the following variable in the C/AL Globals window.

CustomerRec.”No.” := ‘TEST001’;
CustomerRec.TESTFIELD(“No.”,’5000′)

If No. is not 5000, then the following message is displayed:
No. must be 5000 in Customer No.=’TEST001′.

Please comment or post your ideas or questions.

Leave a Reply

Your email address will not be published. Required fields are marked *

Name *
Email *
Website

*

Add User 2013R2

Workflow Dynamics NAV 2016