/// <summary> /// This class is used to handle the event on SalesTable form /// </summary> public static class SM_Sales_SalesTableForm_Extension { /// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> [FormDataSourceEventHandler(formDataSourceStr(SalesTable, SM_SalesTable), FormDataSourceEventType::Writing)] public static void SM_SalesTable_OnWriting(FormDataSource sender, FormDataSourceEventArgs e) { FormDataSource fdsSalesTable = sender.formRun().dataSource("SalesTable"); SalesTable salesTable = fdsSalesTable.cursor(); FormDataSource fdsSMSalesTable = sender.formRun().dataSource("SM_SalesTable"); SM_SalesTable smSalesTable = fdsSMSalesTable.cursor(); if(!smSalesTable.SalesTable) { smSalesTable.SalesTable = salesTable.RecId; } } /// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> [FormDataSourceEventHandler(formDataSourceStr(SalesTable, SM_SalesLine), FormDataSourceEventType::Writing)] public static void SM_SalesLine_OnWriting(FormDataSource sender, FormDataSourceEventArgs e) { FormDataSource fdsSalesLine = sender.formRun().dataSource("SalesLine"); SalesLine salesLine = fdsSalesLine.cursor(); FormDataSource fdsSMSalesLine = sender.formRun().dataSource("SM_SalesLine"); SM_SalesLine smSalesLine = fdsSMSalesLine.cursor(); if(!smSalesLine.SalesLine) { smSalesLine.SalesLine = salesLine.RecId; } } /// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> [FormEventHandler(formStr(SalesTable), FormEventType::Initialized)] public static void SalesTable_OnInitialized(xFormRun sender, FormEventArgs e) { CustParameters custParameters = CustParameters::find(); FormDataSource SM_SalesTable_ds = sender.dataSource(formDataSourceStr(SalesTable, SM_SalesTable)); FormDataSource SM_SalesLine_ds = sender.dataSource(formDataSourceStr(SalesTable, SM_SalesLine)); SM_SalesTable_ds.object(fieldNum(SM_SalesTable, CumulativeGrossWeight)).visible(custParameters.SM_ActivateSOGrossWeightCalculation); SM_SalesLine_ds.object(fieldNum(SM_SalesLine, GrossWeight)).visible(custParameters.SM_ActivateSOGrossWeightCalculation); sender.control(sender.controlId(formControlStr(SalesTable, SM_SalesCalculateCumulativeGrossWeight))).visible(custParameters.SM_ActivateSOGrossWeightCalculation); } } class LogisticsPostalAddressGrid_Eventhandler { /// <summary> /// /// </summary> /// <param name="args"></param> [PostHandlerFor(formStr(LogisticsPostalAddressGrid), formMethodStr(LogisticsPostalAddressGrid, init))] public static void LogisticsPostalAddressGrid_Post_init(XppPrePostArgs args) { FormRun element = Args.getThis(); //form element FormControl myNewButton = element.design(0).controlName("MapButton"); myNewButton.visible(false); } }
This blog is contains coding reference related to Microsoft AX 2012 and D365 finance and operations and Power platform
Monday, April 12, 2021
Form Init, Initialized, writing event handlers in D365fo
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment