Wednesday, June 9, 2021

How to get RecId selected from lookup method?

 How to get RecId selected from the lookup method?. 

public void lookup()
{
    FormRun lookupFormRun;
    Args args;
    MyTable    myLookup;

    args = new Args();
    args.name(formStr(MyNewLookupForm)); // args.caller(this);
    lookupFormRun = classFactory.formRunClass(args);
    lookupFormRun.init();
    this.performFormLookup(lookupFormRun);
    lookupFormRun.wait();
    if (lookupFormRun.closedOk())
    {
        myLookup= formRun.docCursor();
    }
}
Override 'MyNewLookupForm' (new lookup form) init method. Write below logic.
public void init()
{
     super();

     element.selectMode(MainField);
} //MainField -> This is grid field name. Set Auto decleration to Yes.
public void run() // Fileter the selected value in control.
{
    boolean filterLookup;
    FormStringControl callingControl = SysTableLookup::getCallerStringControl(
                                                                   element.args());
    /*filterLookup = SysTableLookup::FilterLookupPreRun(callingControl, 
                                                        Dinosaurs_DinosaurName, 
                                                                Dinosaurs_ds);*/
    super();
 
    SysTableLookup::FilterLookupPostRun(/*filterLookup*/true, 
                                        callingControl.text(), 
                                        Dinosaurs_DinosaurName, 
                                        Dinosaurs_ds);
}


Keep Daxing!!

No comments:

Post a Comment