AX – D365FO – How to access Args Parameters inside dialog() in a runbasebatch class?

 


I want to pass the Args.parm() value from Main() method of a RunBaseBatch to the dialog() method of the same RunBaseBatch.

First of all declare a new string variable called “argsParm” in the declaration method of the RunBaseBatch class and add it to the #localMacro.CurrentList macro

/// </remarks>

class TaxReport extends RunBaseBatch
{
   NoYes                   updateNow;
   TaxPeriod               taxPeriod;
   str                     argsParm;
   #define.CurrentVersion(10)

   #localMacro.CurrentList

       updateNow,

       taxPeriod,
       eraArgsParm


   #endMacro

}

Then create a new method parmArgsParm() in order to access the variable

public str parmArgsParm(str _argsParm = argsParm)
{
   argsParm = _argsParm;

   return argsParm;
}

Then in the Main() method create a new instance of the class and call the parmArgsParm() passing the _args.parm() value

server static void main(Args  _args)

{

   TaxReport                       taxReport;

   NoYes                           updateNow;

   TaxPeriod                       taxPeriod;

   
   taxReport = new TaxReport();

   taxReport.parmArgsParm(_args.parm());

......

   if (taxReport.prompt())

   {

       updateNow         = taxReport.update();

       taxPeriod         = taxReport.taxPeriod();

       fromDate          = taxReport.fromDate();

       transactionDate   = taxReport.transDate();

       settlementAccount = taxReport.parmSettlementAccount();

       taxRepVersion     = taxReport.taxRepVersion();

................
}

Then in the dialog() method you can obtain the argsParm value and do what you want

Object dialog()

{

   DialogRunbase dialog = new DialogRunbase("@SYS23178", this);

   updateNow = false;

   if (argsParm == 'custom')

   {

       dialogUpdate.enabled(false);

       dialogUpdate.value(false);

   }

Comments