FormDataFieldEventType::Validating in D365
/// <summary>
/// Prevent changing the start mileage field on the FMRental form to a value that is equal to 1
/// </summary>
[FormDataFieldEventHandler(formDataFieldStr(FMRental, FMRental, StartMileage), FormDataFieldEventType::Validating)]
public static void StartMileage_OnValidating(FormDataObject sender, FormDataFieldEventArgs e)
{
var dataObject = sender as FormDataObject;
var args = e as FormDataFieldCancelEventArgs;
if (args != null && dataObject != null)
{
var datasource = dataObject.datasource() as FormDataSource;
if (datasource != null)
{
FMRental record = datasource.cursor() as FMRental;
if (record.RecId > 0)
{
if (record.StartMileage == 1 )
{
boolean doCancel = !checkFailed("Start Mileage = 1 is not allowed");
args.cancel(doCancel);
}
}
}
}
}
Thanks,
Vikas Mehta.
No comments:
Post a Comment