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

Convert Call stack to readable format in D365FO X++

//Input --container _xppCallStack = xSession::xppCallStack();  Public static str POL_formatXppCallStack(container _xppCallStack, int _skipFr...