AX7/D365/Operations: Enable/Disable form control in X++
https://dynamicsaxinsight.wordpress.com/2017/09/12/ax7-d365-operations-enable-disable-form-control-in-x-plus-plus/
Purpose:
The purpose of this document is to demonstrate how we can enable/disable a form control in X++ based on a business logic.
Product:
Dynamics 365 for Finance and Operations, Platform Update 9.
Development approach:
Customization through extension.
Development:
- Create a post event handler of a standard form method enabling/disabling the form controls. In this case, we are creating a post event handler of a standard method setFieldAccessHeader of SalesQuotationProjTable form.
- Please find the event handler method definition as follows.
[PostHandlerFor(formStr(SalesQuotationProjTable), formMethodStr(SalesQuotationProjTable, setFieldAccessHeader))] public static void SalesQuotationProjTable_Post_setFieldAccessHeader(XppPrePostArgs args) { FormRun sender = args.getThis(); FormDataSource salesQuotationTable_ds; SalesQuotationTable salesQuotationTable; salesQuotationTable_ds = sender.dataSource(1); salesQuotationTable = salesQuotationTable_ds.cursor(); sender.control(sender.controlId(formControlStr(SalesQuotationProjTable, DeviceUsageGroup))).enabled((salesQuotationTable.AMDeviceId) ? true : false); }
Comments
Post a Comment