Skip to main content

Args class in Axapta


 

The Args system class is one of the most widely used classes in Axapta.
 Args is an abbreviation for arguments and an Args object is used to
pass information from one object (caller) to another newly created object.

Using Args for object creation
Args    args = new Args("CustTable");
FormRun formRun = ClassFactory.formRunClass(args);
;
formRun.init();
formRun.run();
formRun.wait();

caller:

public Object caller( [Object _value] )

This method gets or sets the calling object.
 When creating an args object directly through code,
 the caller will not be automatically set, so you should set it yourself.

Record:

public Common record( [Common _value] )

this method gets or sets a table buffer (record) attached to the Args.
 A buffer of any table can be attached to an Args object using this method. 
Be aware when retrieving the buffer that there will be no compile-time check of table id. 
You should use the dataset method below to check the contents of the buffer.
If the caller and callee are on different tiers, 
then the applications will automatically copy the buffer to the target tier.

Dataset:

public tableId dataset()

this method gets the table Id of a table buffer (record) attached to the Args.
To safely retrieve an attached record from an Args object,
use code similar to that shown below.
This checks to ensure that there is an attached record,
and that it is in fact a SalesTable record, before trying to assign it to the salesTable variable.

if (args.record() && args.dataset() == tableNum(SalesTable))
salesTable = args.record();

parm:

public str parm( [str _value] )
parm is used to pass a string variable to the called object

parmEnum:

public anytype parmEnum( [int _value] )
see parmEnumType

parmEnumType:

public int parmEnumType( [int _value] )
parmEnum and parmEnumType are used together to pass a Base Enum value through to the called object. An example is shown below.
args.parmEnumType(EnumNum(AddressType));
args.parmEnum(AddressType::Delivery);

parmObject:

public Object parmObject( [Object _value] )
parmObject is used to pass a reference to any object to the called object.
Be aware of client-server issues if the caller and callee are on different tiers.

menuItemName:

public final str menuItemName( [str _value] )

menuItemType:

public final MenuItemType menuItemType( [MenuItemType _value] )
A short tutorial on how to open a form in Dynamics Ax (Axapta) by code.

Just take a line of code:

new MenuFunction(MenuItemDisplayStr(CustTable),MenuItemType::Display).run();

The above code will open the CustTable form. That's all it takes.
Now if you want to supply some arguments to the opening form,
 this is also possible with the optional args parameter.

static void FormOpen()
{
Args args = new Args();
;
args.record(CustTable::find('CUS-001'));
new MenuFunction(MenuItemDisplayStr(CustTable),MenuItemType::Display).run(Args);
}

This code will open the CustTable form and filter out the
customer with accountnumber CUS-001.

Enjoy Daxing..

Comments

Popular posts from this blog

Using File path on a form getting Error in Axapta

Hi Folks, After a long time am coming  back to posting few new things here for AX Developer... When we want to select the file path in form level. Normally what we will do create one EDT and extends with filepath (EDT), but that time when you are trying to select the path we will get error like stack-trace/Error message .Don’t worry there is no problem with your ax application. Simple we need to provide the method to the form like filepathLookUpTitle (). Below method we need to add it into form level methods, i.e. str filePathLookupTitle() {     return "Select document folder"; } Thanks Happy Daxing....

How to add Filter functionality to Display method in dynamics AXAPTA

Hi Friends, Normally filters will work only in table fields but we can't do filters to display method. This below code will work for filters to display method also. Step 1: Go to the form design right click on particular control properties Auto Declaration No to Yes. Step 2: Override the context() method on the display method  . public void context() {     int             selectedMenu;     formrun         fr;     Args            ag;     Name            strtext;     querybuilddataSource qb1;     queryrun    qr;     query       q;     PopupMenu menu = new PopupMenu(element.hWnd());     int a = menu.insertItem('Filter By Field');     int b = menu.insertItem('Filter By Selection');     i...

Split string useing List in AX2009

static void Job277(Args _args) {     List _list = new List(Types::String);     Container packedList;     ListIterator iterator;     str cade = "Jhon*,smt*,and*,caro*";     ;     _list = Global::strSplit(cade,",");     iterator = new ListIterator(_list);     while(iterator.more())     {         packedList += iterator.value();         iterator.next();     }     info(conpeek(packedList,2));     info(strfmt("%1",conlen(packedList)));   }