AX 2009 - How to check if fields have been changed in Form

Hi,

I have 50 fields in a Form. I want to know whethere user has changed value in any of the fields on Form. I want to know this at FIELD level not at RECORD level. I mean, the moment user leaves a field by changing it’s value, my validation should execute. Though there is validateWrite() method on DataSource but it executes when you leave current record. And also I do not want to write code on every 50 field’s “modified” method.

Thanks in advance. :slight_smile:

try using modifiedfield() method at table level

regards,

narayan

ValidateField() at table level…

Actually I have to validate my code for few fields only, say 12 fields on SalesLine. I wrote my code on SalesLine table’s “modifiedfields” method to ignore my validation for these 12 fields. It was working fine. But when I post Sales Invoice then system is executing this validation as well (might be system is modifying some of fields on SalesLine after posting). That is why I am trying to write this validation on Form level instead of Table level.

Below is code that I wrote on SalesLine table’s “modifiedField” method.

public void modifiedField(fieldId _fieldId)

If ( _fieldId != fieldnum(SalesLine, && _fieldId != && _fieldId != ) // say there are three field which should excluded for validation

{ // if field which is being modified is not any of above three, then check for sales document status

If ( _salesTable.SalesDocumentStatus == SalesDocumentStatus::Released) // SalesDocumentStatus is new field on SalesTable table.

{

throw error(‘Cannot modify record. Document must be in “Open” mode’) ;

{

}

Generally the validation should be handled in Validate* methods either at the form or table level…

Why don’t you setup database log on the tables for EDIT operation. It shows all the details for any column or field value changes.

It will not propably do the validation.

It is done. I written the code on “validateField” method of Table. Like this :

if (this.isFormDataSource())
{
if (this.orig().(fieldId) != this.(fieldId))
{
if (fieldId != fieldnum(SalesTable, FreightPaymentType) && fieldId != fieldnum(SalesTable, VehicleNo) &&
fieldId != fieldnum(SalesTable, TransporterAccount) && fieldId != fieldnum(SalesTable, SalesTaxFormType_IN) &&
fieldId != fieldnum(SalesTable, ManualFormNo) && fieldId != fieldnum(SalesTable, BiltyNo) &&
fieldId != fieldnum(SalesTable, BiltyDate) && fieldId != fieldnum(SalesTable, InvoiceAccount) &&
fieldId != fieldnum(SalesTable, PaymMode) && fieldId != fieldnum(SalesTable, CreditTakenReverse))
this.TestStatus(this, true) ; // TestStatus is a method on SalesTable table.
}
}

void TestStatus(SalesTable _salesTable, boolean _dataModifiedByUser)
{
if (_dataModifiedByUser)
{
if (_salesTable.SalesDocumentStatus == SalesDocumentStatus::Released)
{
throw error(‘Sales Document Status must be Open’) ;
}
}
}

Anyhow, thanks Kranthi & Syed for your support.

Hi,

i have a form with grids i have entered 10 records later i want to know user has changed the records r not.there is no post buttons.the how to write validate feild can u plz help me