50) How to create the EventHandler in D365
/// <summary>
/// The <c>AVAEntAssetWorkOrderTableFrm_EventHandler</c> contains the TransMountain extending logic for the <c>EntAssetWorkOrderTable</c> form.
/// </summary>
class AVAEntAssetWorkOrderTableFrm_EventHandler
{
/// <summary>
/// Enable and disable the fields and button on the condition workorder type is pipeline
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
[FormDataSourceEventHandler(formDataSourceStr(EntAssetWorkOrderTable, WorkOrderTable), FormDataSourceEventType::Activated)]
public static void WorkOrderTable_OnActivated(FormDataSource sender, FormDataSourceEventArgs e)
{
FormRun formRun = sender.formRun();
FormDataSource entAssetWorkOrderTable_ds = formRun.dataSource(formDataSourceStr(EntAssetWorkOrderTable, WorkOrderTable)) as FormDataSource;
EntAssetWorkOrderTable entAssetWorkOrderTable = entAssetWorkOrderTable_ds.cursor();
FormControl dpmsUrlButton = formRun.design().controlName(formControlStr(EntAssetWorkOrderTable, AVADpmsUrlLink)); // Form button control name
boolean enableDPMSButton = (entAssetWorkOrderTable.workOrderType().AVAWorkOrderTypeClassification == AVAWorkOrderTypeClassification::Pipeline);
entAssetWorkOrderTable_ds.object(fieldnum(entAssetWorkOrderTable, AVAYearofIssue)).enabled(enableDPMSButton);
entAssetWorkOrderTable_ds.object(fieldnum(entAssetWorkOrderTable, AVAKMPost)).enabled(enableDPMSButton);
entAssetWorkOrderTable_ds.object(fieldnum(entAssetWorkOrderTable, AVAEnableDPMS)).enabled(enableDPMSButton);
// Form control button
dpmsUrlButton.enabled(enableDPMSButton);
}
}
Note: - here you can write the multiple extension if the you are written for the same Form
Comments
Post a Comment