Showing posts with label ax - FormRun class. Show all posts
Showing posts with label ax - FormRun class. Show all posts

Monday, November 27, 2017

AX - How pass table (datasource) as param to form

In menu item on caller form you must define DataSource property:







This ProdTable will be passed as parameter to called (here) form.

In called form you override init() method:

FormRun callerForm;
FormDataSource callerDataSource;
...
public void init()
{
    super();

    if ( element.args() && element.args().caller() )
    {
        callerForm = element.args().caller();

        if ( callerForm && callerForm.dataSource() ) {

            /* -- save DataSource */

            callerDataSource = callerForm.dataSource();

            /* -- call check method */

            this.check();
        }

    }
}

Thursday, November 23, 2017

AX - How call form with param

Calling form with passing parameter - here it is one passed value (ProdId type):
void Check()
{
  Args args;

  FormRun formRun;

  /* -- call check form */

  args = new args();

  if ( jmgJobTable )
    args.parm( JmgJobTable.ModuleRefId );
  else
    args.parm( "" );

  ags.name( formstr( CheckBus ) );
  formRun = classFactory.formRunClass( args );
  formRun.init();
  formrun.run();
  formrun.wait();
}
..and here is receiving part - in form init() method:
public void init()
{
  ProdId prodId;

  super();

  if( element.args() )
  {
    /* -- get param value */

    prodId = element.args().parm();     
    EProdId.text( prodId );
    EOutput.text( "" );

    EProdId.setFocus();
  }
}