Purpose:
The purpose of this post is to share examples of extensions.
Product:
Dynamics 365 for Finance and Operations
Code:
Form data source event handler. Event type: ValidatedWrite
/// <summary>
/// OnValidatedWrite handler
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
[FormDataSourceEventHandler(formDataSourceStr(DirPartyQuickCreateForm, DirPartyTable), FormDataSourceEventType::ValidatedWrite)]
public static void DirPartyTable_OnValidatedWrite(FormDataSource sender, FormDataSourceEventArgs e)
{
#define.CallerFormName("CustTable")
FormRun formRun = sender.formRun();
FormDataSource dirPartyTable_DirOrganization_ds = formRun.dataSource(formDataSourceStr(DirPartyQuickCreateForm, DirPartyTable_DirOrganization));
DirOrganization dirOrganization = dirPartyTable_DirOrganization_ds.cursor();
FormDataSourceCancelEventArgs args = e as FormDataSourceCancelEventArgs;
boolean doCancel;
if (formRun.args().callerName() == #CallerFormName)
{
if (!dirOrganization.OrgNumber)
{
checkFailed(strFmt("Organization number is required."));
doCancel = true;
}
}
args.cancel(doCancel);
}
Form event handler. Event type: Initialized
/// <summary>
/// OnInitialized handler
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
[FormEventHandler(formStr(DirPartyQuickCreateForm), FormEventType::Initialized)]
public static void DirPartyQuickCreateForm_OnInitialized(xFormRun sender, FormEventArgs e)
{
#define.CallerFormName("CustTable")
if (sender.args().callerName() == #CallerFormName)
{
DimensionEntryControl dimensionEntryControl = sender.control(sender.controlId("DimensionEntryControl"));
dimensionEntryControl.parmDisplayValues(true);
}
}
*This post is locked for comments