Axaptapedia is now maintained by AgileCadence For more information please click here.

Args Class

From Axaptapedia
Jump to: navigation, search

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[edit]

The Args object can also be used to assist in object creation, in conjunction with the ClassFactory. For example, to open a CustTable form, you can use the following code: <xpp>

Args    args = new Args("CustTable");
FormRun formRun = ClassFactory.formRunClass(args);
;

formRun.init();
formRun.run();
formRun.wait();

</xpp>

Methods and Properties[edit]

caller[edit]

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[edit]

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[edit]

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();

lookupField[edit]

public fieldId lookupField( [fieldId _value] )

see lookupValue

lookupValue[edit]

public str lookupValue( [str _value] )

lookupField and lookupValue are used together. When they are filled with a field Id and value, it indicates that a form opened using the current Args object will automatically select a record based on that criteria.

For example, the following code assumes that a customer with the account code "1000" exists. It will open the CustTable form with customer '1000' selected, but with the other customers still shown. This is the same result visually as is achieved using the Go to Main Table function in Axapta 3.0 and higher. <xpp>

Args    args = new Args("CustTable");
FormRun formRun;
;

// Look up customer 1000 when the form opens
args.lookupField(fieldNum(CustTable, AccountNum));
args.lookupValue("1000");

formRun = ClassFactory.formRunClass(args);

formRun.init();
formRun.run();
formRun.wait();

</xpp> Note that this lookup is extremely fast, and should be used in preference to calling .findValue or .findRecord once the form has opened.

parm[edit]

public str parm( [str _value] )

parm is used to pass a string variable to the called object

parmEnum[edit]

public anytype parmEnum( [int _value] )

see parmEnumType

parmEnumType[edit]

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[edit]

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[edit]

public final str menuItemName( [str _value] )

menuItemType[edit]

public final MenuItemType menuItemType( [MenuItemType _value] )

Examples[edit]