SysTableLookup can be used in dialogs to create custom
lookups.
control.registerOverrideMethod can be used to register the
methods to override by an object
Here is the example which shows basic usage of both. We will
create a dialog and get a lookup of account numbers on a control
protected Object dialog()
{
FormStringControl
control;
;
dialog = super();
dialogFeildAccountNum = dialog.addField(extendedTypeStr(AccountNum));
control =
dialogFeildAccountNum.control();
control.registerOverrideMethod(methodStr(FormStringControl, lookup), methodStr(DialogLookup,
accountNumLookup),
this);
return dialog;
}
Here is the method:
private void
accountNumLookup(FormStringControl _control)
{
SysTableLookup sysTableLookup;
QueryBuildDataSource queryBuildDataSource;
Query query = new Query();
queryBuildDataSource = query.addDataSource(tablenum(CustTable));
sysTableLookup =
SysTableLookup::newParameters(tablenum(CustTable), _control);
sysTableLookup.addLookupfield(fieldnum(CustTable,
AccountNum), true);
sysTableLookup.parmQuery(query);
sysTableLookup.performFormLookup();
}
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
Thanks for the tutorial. However i keep getting this error :
ReplyDeleteError executing code: FormStringControl (object), method Lookup called with invalid parameters.
I had the same issue, and like many annoying things with annoying AX, all that was required was a restart of my development environment. Now I hit my breakpoint in the new target method without issue.
DeleteHi,
ReplyDeletewhat is DialogLookup, class?
great it works! you saved the day :D
ReplyDeletegreat. thanks
ReplyDelete