This post is machine-translated. The original post in german language can be found here.

Show only active employees in an employee-lookup

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.

Screenshot

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.

Screenshot

By the way: The class HcmWorkerLookup offers a lot of similar static methods like the above used newActiveAmployees().

These post applies to following version:
Dynamics AX 2012

Add comment
 
 

 

 
 
 
Posts of the actual month
März 2024
MoTuWeThFrSaSu
 123
45678910
11121314151617
18192021222324
25262728293031
 
© 2006-2024 Heinz Schweda | Imprint | Contact | German version | Mobile version
In order to provide you with better service, this site uses cookies. By continuing to browse the site, you are agreeing to our use of cookies.