D365/AX7:Form Datasource Field Event or Data Event “onValidating”


Demonstration of Form Datasource Field Event or Data Event “onValidating”.Validating field values in form level.

Sample Code

  1. Create a new class.
  2. Copy “onValidating” event from Form Datasource field & paste the same into the class.

[code language = “cpp”]
[FormDataFieldEventHandler(formDataFieldStr(SalesTable, SalesLine, SalesPrice), FormDataFieldEventType::Validating)]
public static void SalesPrice_OnValidating(FormDataObject sender, FormDataFieldEventArgs e)
var args = e as FormDataFieldCancelEventArgs;
FormRun formRun = sender.datasource().formRun();
boolean ret;
SalesTable salesTable = formRun.dataSource(formdatasourcestr(SalesTable, SalesTable)).cursor();
SalesLine salesLine = formRun.dataSource(formdatasourcestr(SalesTable, SalesLine)).cursor();
formRun = sender.datasource().formRun();
if (CustTable::find(salesTable.CustAccount).AcxOverrideSalesPrice == NoYes::Yes && salesLine.SalesQty > 0)
ret = checkFailed(‘Override Sales Price Is True On Customer Card.’);

cheers 🙂
piyush adhikari

One thought on “D365/AX7:Form Datasource Field Event or Data Event “onValidating””

Leave a Reply