Monday, June 02, 2008

Args class

Args-Object

The Args-class defines the communication between running application objects.The application object that initiates the communication (the caller), is initializing an args object that has information and passes it to the application object that is called:

Caller --------> Args ---------> Called

Different Methods of Args Class

Caller ----------> A handle to the caller object.With this it is possible for the application object called to activate methods on the caller.

EX:

if (!element.args().caller())
{
//The form cannot be called directly.

throw error("@SYS96590");
}


dataset ---------------> The Id of the table that the caller object currently is working on. This information is typically used to verify which type of record that is transferred.


record ------------------> A handle to the record that the caller currently is working on.This information is typically used to access the values of the caller’s
record. Remember to check the table before you assigns this handle into a specific table variable.

EX:

if (element.args().dataset() == tablenum(custTable))
{
custTable = element.args().record();
}

parmEnumType -------------> The Id of the enum that is specified on the command.

parmEnum ---------------> The entry of the enum that is specified on the menu item.

parm ---------------> A string which can be used to transfer information. It is best practice not to use this method. Try to build the communication
on the information above.

EX:

ItemType itemType;
str parm;

if(element.args().parmEnumType() == enumNum(ItemType))
{

itemType = element.args().parmEnum(); // itemType (ITEMS,BOM,SERVICE)

parm = element.args().parm(); // to access the parm string given on Menuitem

}


To call a form Ffrom X++

Args args = new Args();

args.name(formstr(salesTable));

args.caller(this);

args.record(custTable); //a specific custtable record

formRun = classfactory.formRunClass(args);

formRun.init();

formRun.run();

formRun.wait();


To call a form's menuitem from X++

Args args;

FormRun formRun;
;

args = new Args();

args.caller(this);

args.record(_record);

args.parmObject(_formRun);

formRun = new MenuFunction(menuitemdisplaystr(custTable), MenuItemType::Display).create(args);

No comments: