Friday, March 21, 2014

Form Lookup thorugh code

// Form Lookup thorugh code

public void lookup()

{
    HcmWorker               selectedRecord;
    Args                    args;
    FormRun                 formRun;
    Form                    workerLookupForm = new Form(formStr(HcmWorkerLookup));
    FormControl             control = this;
    FormStringControl       stringControl       = control as FormStringControl;

    args = new Args();
    args.name(formStr(HcmWorkerLookup));
    args.caller(this);

    args.parmObject(this);

    // position the lookup to highlight the current record
    // a string control supposed to contain a personnel number value
    selectedRecord = HcmWorker::findByPersonnelNumber(stringControl.text());

    if (selectedRecord.RecId != 0)
    {
        args.lookupRecord(selectedRecord);
    }

    // perform form lookup on the caller form control
    formRun = FormAutoLookupFactory::buildLookupFromCustomForm(stringControl, workerLookupForm , AbsoluteFieldBinding::construct(fieldStr(HcmWorker, PersonnelNumber), tableStr(HcmWorker)), args);
    stringControl.performFormLookup(formRun);

    //selectedRecord = formRun.selectRecordModeSelectedRecord();

}

No comments:

Post a Comment

Copy Markup charges while posting purchase invoice using X++

 Copy Markup charges while posting purchase invoice using X++ Class: Important: Code logic is just for Reference.  New class => Duplicate...