This post is machine-translated. The original post in german language can be found here.
These post applies to following version:
Dynamics AX 2012
Dynamics AX 2012
|
|
|
|
|
|
|
This post is machine-translated. The original post in german language can be found here.
These post applies to following version:
Dynamics AX 2012
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
I recently had the requirement to integrate a new field for an employee in a table. So i created a table relation to Table HcmWorker, and added the field to the form.
Thus, a Reference Group was created and Dynamics AX generated the following lookup.
But the requirement was to offer only certain employees in the lookup. To do this i have overwritten the method lookupReference() of the field (the table DEV_TestTable was the only DataSource in form) as follows:
public Common lookupReference(FormReferenceControl _formReferenceControl) { Common ret; FormReferenceGroupControl callingReferenceGroupControl; FormRun lookupForm; Args args; HcmWorkerLookup hcmWorkerLookup; if (!_formReferenceControl) { throw(error(strFmt("@SYS137393", Error::wrongUseOfFunction(funcName())))); } hcmWorkerLookup = hcmWorkerLookup::newActiveEmployees(); args = new Args(formStr(HcmWorkerLookup)); args.parmObject(hcmWorkerLookup); args.record(DEV_TestTable); args.caller(_formReferenceControl); lookupForm = classfactory.formRunClass(args); lookupForm.init(); if (_formReferenceControl.handle() == classNum(FormReferenceGroupControl)) { callingReferenceGroupControl = _formReferenceControl; callingReferenceGroupControl.performFormLookup(lookupForm); ret = lookupForm.selectRecordModeSelectedRecord(); } return ret; }By adjusting the lookup form like this, now only active employees will be displayed.
By the way: The class HcmWorkerLookup offers a lot of similar static methods like the above used newActiveAmployees().