Hi guys, Today we see how to create a simple dialog and how to override its methods. Instead of creating run base batch we can follow the below code. But this code is not run in the batch. For your reference I created the dialog with simple info process and I have override the 2 methods.
Check below.
class TestCustomers { container conSales; DialogField dialogField1, dialogField2, dialogField3; public static void main(Args _args) { CustTable custTable; TestCustomers customers = new TestCustomers(); custTable = _args.record(); if(_args && _args.dataset() == tableNum(CustTable)) { customers.rundialog(custTable); } } // creating dialog from this method public void rundialog(CustTable custTable) { Dialog dialog; dialog = new Dialog(); dialog.caption('Customer salesOrders'); dialogField1 = dialog.addField(ExtendedTypeStr(NoYesId)); dialogField2 = dialog.addField(ExtendedTypeStr(CustAccount)); dialogField3 = dialog.addField(ExtendedTypestr(SalesId)); dialogField2.value(custTable.AccountNum); //dialogField1.allowEdit(false); dialogField1.label('check'); // Override Lookup, modified methods. dialogField1.registerOverrideMethod(methodStr(FormStringControl, Modified), methodStr(TestCustomers, enableOnModified), this); dialogField3.registerOverrideMethod(methodStr(FormStringControl, lookup), methodStr(TestCustomers, salesOrderLookup), this); dialog.run(); if(dialog.closedOk()) { if(dialogField1.value()) { info(strFmt('%1 - %2', dialogField2.value(), dialogField3.value())); //FormDataUtil::getFormDataSource(custTable).refresh(); } else { checkFailed("Value should be mandatory"); } } } private void salesOrderLookup(FormStringControl _control) { Query query; QueryBuildDataSource qbds; query = new Query(); qbds = query.addDataSource(tableNum(SalesTable)); qbds.fields().clearFieldList(); qbds.addSelectionField(fieldNum(SalesTable, SalesId)); qbds.addSelectionField(fieldNum(SalesTable, CustAccount)); // In D365 // SysLookupMultiSelectGrid::lookup( query, _control, _control,_control,conSales); SysLookupMultiSelectGrid::lookup(query, _control, _control,conSales); // In 2012 } public boolean enableOnModified(FormCheckBoxControl _control) { // The below decleration is to access all methods of control. FormStringControl salesOrder = dialogField3.control(); NoYesId check = _control.checked(); dialogField2.enabled(check); salesOrder.enabled(check); salesOrder.mandatory(check); return true; } }
Keep Daxing!!
No comments:
Post a Comment