Wednesday, 12 August 2020

FormDataSourceEventType::ValidatingWrite in d365

 FormDataSourceEventType::ValidatingWrite in d365

/// <summary>

/// When saving a new rental, prevent setting the start mileage on the FMRental 

/// </summary>

[FormDataSourceEventHandler(formDataSourceStr(FMRental, FMRental), FormDataSourceEventType::ValidatingWrite)]

public static void FMRental_OnValidatingWrite(FormDataSource sender, FormDataSourceEventArgs e)

{

    var datasource = sender as FormDataSource;

    var args = e as FormDataSourceCancelEventArgs;

    if (args != null && 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

AZURE INTERVIEW QUESTIONS AND ANSWERS

AZURE INTERVIEW QUESTIONS AND ANSWERES 2021 2. What is cloud computing? Explanation:  It is the use of servers on the internet to “store...