How to create a lookup method on a form without writing any code on form and using event.
AX 7 provides a very nice feature called Events. Using that concept lookup can be build on form level without touching any code on that form. See the procedure below.
I added a new string field on InventBatch form using extension. I have requirement to create lookup on this field. Lets start the steps of doing
2. Create a class InventBatchEventHandler and paste.
Build the project and you will have the new lookup on control.
Please enjoy learning and comment below if you have any query or suggestion.
AX 7 provides a very nice feature called Events. Using that concept lookup can be build on form level without touching any code on that form. See the procedure below.
I added a new string field on InventBatch form using extension. I have requirement to create lookup on this field. Lets start the steps of doing
- Go to that control on form,expand the events node and click on copy event handler method.
2. Create a class InventBatchEventHandler and paste.
- class InventBatchEventHandler
- {
- /// <summary>
- ///
- /// </summary>
- /// <param
name="sender"></param>
- /// <param
name="e"></param>
-
[FormControlEventHandler(formControlStr(InventBatch, VesselName),
FormControlEventType::Lookup)]
- public static void
VesselName_OnLookup(FormControl sender, FormControlEventArgs e)
- {
- SysTableLookup sysTableLookup =
SysTableLookup::newParameters(tablenum(VesselTable),
sender);
- Query query = new Query();
- QueryBuildDataSource qbds;
-
sysTableLookup.addLookupField(fieldnum(VesselTable, VesselId), true);
-
sysTableLookup.addLookupField(fieldnum(VesselTable, Name));
- qbds =
query.addDataSource(tablenum(VesselTable));
-
sysTableLookupCreate.parmQuery(query);
-
sysTableLookup.performFormLookup();
-
FormControlCancelableSuperEventArgs ce = _e as FormControlCancelableSuperEventArgs;
- //cancel super() to prevent error.
- ce.CancelSuperCall();
- }
- }
Please enjoy learning and comment below if you have any query or suggestion.











