Friday, July 13, 2018

Args Object

The Args class defines information communicated between running application
objects. The application object that initiates the communication (the caller),
initializes an
Args object containing some information and then passes it to the
application object that is being called.
Information transferred by the args object includes the following:

Method Data Type Information
record Common A handle to the record that the caller is
currently using. This information is
typically used to access the values of the
caller's record.
parmEnumType Int The Id of the enum type that is specified
on the parmEnum.
parmEnum AnyType An enumerated value.
parmObject Object A handle to an object that the caller wants
to transfer to the called object. This
option can be used to transfer any object.
parm Str A string which can be used to transfer
miscellaneous information. It is best
practice not to use this method. Try to
build the communication on the other
parm methods available.

Communication through the args object can occur automatically without any
X++ programming.
If the caller is activating the called object by a menu item the
Args object is
automatically initialized and sent as a parameter to the object called.
AOTproperties of the menu item will be used.
If the called object is a form or a report, it can automatically apply to the
information send by the
Args object. Forms will automatically try to make a
delayed synchronize with the
args.record().
However, you can program one or both sides of the communication yourself.

The following is an example of code on the caller side(\Classes\LedgerConsolidate\dialog). 
  

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
Object dialog()
{
  Args args;
  FormRun formRun;
  mayBeExecuted = false;
  args = new Args();
  args.name(formStr(LedgerConsolidate));
  args.caller(this);
  formRun = 
  ClassFactory::formRunClassOnClient(args);
  formRun.init();
  return formRun;
}

This code shows an example of how to replace a dialog object with a form from
the
AOT, within the RunBase framework. The form called can access the
LedgerConsolidate class through
args.caller(). This way, the form and class can
exchange information.
The following is an example of programming the called side
(Classes\BankChequeCancel\main).


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
public static void main(Args args)
{
BankChequeCancel chequeCancel;
Args localArgs = new Args();
;
if (args.record())
{
switch (args.dataset())
{
case tablenum(BankChequeTable) :
chequeCancel =
BankChequeCancel::newBankChequeTable(args.record());
break;
default :
throw
error(strfmt("@SYS22828","@SYS22512"));
}
if (chequeCancel.prompt())
{
localArgs.caller(chequeCancel);
localArgs.record(args.record());
BankChequeCancel::serverRun(localArgs);
}
}
}

Notice that this method also declares, initializes, and uses a local Args object for
calling the static method
BankChequeCancel::serverRun().
Best Regards,
Hossein Karimi

No comments:

Post a Comment

Configure the Firewall on the Enterprise Portal Server

After you install Enterprise Portal, enable Web Server (HTTP) in Windows Firewall. If you do not enable the web server in Windows Firewall...