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....

Convert word Documents into PDF report [using X++ in Dynamics AX 2009]

Hi Friends, This is the way we can convert word format report into PDF in ax2009 static void dsiple_PDS(Args _args) {     Args args;     ReportRun rr;     str reportName = "ReportName";     PurchRFQLine rfqLineTable;     str myPath;     str pdfFileName;     int i;     COM wordApplication;     COM wordDocuments;     COM wordDocument;     COM wordRange;     str a[];     str path;     str pdfPath;     str finalPath;     int length;     int minus;     ;     i = 1;     myPath = winApi::getTempPath();     info(myPath);     args = new Args(reportName);     args.caller(rr);     //rr =...

AIF (Endpoint) Error : The user is not authorized to perform this action.

"The user is not authorized to perform this action."  We started getting this error message in our AX 2009 System, when ever we try to consume an XML file using an  Endpoint   thru a  File System  Channel to create a  Sales Order. We did not made any code changes / setup changes, but all of the sudden started getting this error. Solutions : 1. Validate the "SourceEndpointUser". in inbound XML  The User ID should be a valid user Id in DAX, in GNS Active Directory and the "\" should be back slash in the XML file or where you use this combination in entire process or setup. ex : Domain \ User Id. In our case when we had the above error, the SourceEndPointUser user id was deleted from the Active Directory in GNS, so we added it back to Active Directory then it solved the problem. NOTE : If nothing wrong with the User ID, try to add the user id in "Users" tab in Endpoints form for that End Point used by the process. 2. Verify th...