Oct 23, 2012

How to filter the records in dialog field values ?


The following example class is to filter the records in a dialog fields

class TestDialogFields
{
    Dialog                       dialog;   
    DialogField              emplIdField;
}

Dialog showDialog()
{
    FormRun        formRun;
    ;
    dialog         = new Dialog('Dialog fields test');   
    emplIdField = dialog.addField(typeId(emplid));
    dialog.run(true);
    dialog.formRun().controlMethodOverload(true);
    dialog.formRun().controlMethodOverloadObject(this);
    return  dialog;
}

public void Fld1_1_lookup()
{
    FormStringControl        control               = dialog.formRun().controlCallingMethod();
    SysTableLookup          sysTableLookup =  SysTableLookup::newParameters(tablenum(EmplTable), control);
    Query                         query                = new Query();
    QueryBuildDataSource                          queryBuildDataSource;
    EmplTable                                            EmplTable;
    ;
   
    sysTableLookup.addLookupfield(fieldnum(EmplTable, EmplId));
    sysTableLookup.addLookupfield(fieldnum(EmplTable,EmplIdentNumber ));
    queryBuildDataSource = query.addDataSource(tablenum(EmplTable));
    queryBuildDataSource.addRange(fieldnum(EmplTable,EmplId)).value(queryRange("1000","2000"));
    sysTableLookup.parmQuery(query);
    sysTableLookup.performFormLookup();
}

public static void main(Args args)
{
     TestDialogFields testDialogFields = new TestDialogFields();
     ;
     testDialogFields.showDialog();
}

How to open a a form on button click ?


void clicked()
{
    Menufunction       menufunction ;
    Args                    args = new Args();
    FormRun              formRun;
    ;
    
    if(MyTable.StatusId == " ")
    {
        throw error("Please fill the StatusId of the record ");
    }
    else
    {
    args.record(MyTable);
    menufunction  = new Menufunction(menuitemdisplaystr(MyTrans),menuItemType::Display);
    formRun         = menufunction.create(args);
    formRun.run();
    formRun.wait(true);
  
      }
   
}