public void Fld1_1_lookup()
Instead use the new method introduced in Dynamics AX 2012, the DialogField.registerOverrideMethod method.
The method is very straightforward: you indicate what method you want to override, what is the method that overrides it, and in which form you want it to be overridden. Since it works with dialogs, you can use it on SysOperation UI Builders, on forms' dialogs and so on.
Because this method requires that the dialog is already constructed, you usually put it in "postRun" methods, like dialogPostRun or simply postRun, it depends on what you're doing. For SysOperationUIBuilders, you should call this method on the postBuild method.
For what I've seen and tested, the method that will receive the "event" we have overridden must always accept a first parameter of type FormControl, otherwise it just won't work.
Your method should look something like this:
private void lookup(FormControl _formControl)
Here's a full example of a lookup for a SysOperationUIBuilder, where we will override a lookup for a dialog field bound to the data contract:
- Here we register the method that will be used to override the lookup method
public void postRun() { DialogField dlgFieldToBeOverridden; MyDataContract dataContract; super(); dataContract = this.getDataContractObject(); dlgFieldToBeOverridden = this.bindInfo().getDialogField(dataContract, methodStr(MyDataContract, parmFieldToBeOverridden)); dlgFieldToBeOverridden.registerOverrideMethod(methodStr(FormStringControl, lookup), methodStr(MyUIBuilderClass, myCustomLookup), this); }
- And here's the method that will perform the actual lookup. For this particular example, we will assume we already have developed a new form called "MyLookupForm", and that we will be performing the lookup from a string control. You could use the SysTableLookup or the SysReferenceTableLookup approaches instead.
private void myCustomLookup(FormControl _formControl) { Args args = new Args(formStr(MyLookupForm)); FormStringControl stringControl = _formControl; FormRun formRun; formRun = ClassFactory::formRunClassOnClient(args); formRun.init(); stringControl.performFormLookup(formRun); }
Nicely explained. I have shared this link on my blog as well.
ReplyDeletehttp://axrachit.blogspot.com.au/2013/09/ax2012-custom-lookup-on-dialog-control.html
dataContract = this.getDataContractObject();
ReplyDeleteJust a small notice for D365 users, the correct method would be this.dataContractObject();
as "getDataContractObject();" method doesn't exist on SysOperationUIBuilder class