Thursday 24 December 2015

Date Lookup in string control

Sometimes, you may need to lookup the date calendar in a string control. This was easily possible by overriding the lookup function and call the below method in the AX older versions.
public void lookup()
{
    ;

    this.performFormLookup(SysLookup::LookupDate());
}


But in AX2012R2 you cannot use the lookupDate function like this because it is made protected and can only be used by functions in the classes which are derived from SysLookup.
Its work around is to directly call the SysDateLookup form.
The code is as below.


public void lookup() // Form control lookup
{
    FormRun formRun;
    Args    args;
    ;

    args        = new Args(formStr(SysDateLookup));
    args.caller(element);
    formRun     = classfactory.formRunClass(args);
    formRun.init();
    this.performFormLookup(formRun);
}

No comments:

Post a Comment