Showing posts with label args. Show all posts
Showing posts with label args. Show all posts

28 Jan 2015

Pass values between form and report +AX

Here is for example the code of the button that calls the report:

void clicked()
{
Args args;
ReportRun reportRun;
;
super();
args = new Args();
args.name(Reportstr(HistoryHolidays));
args.parm( LogId );
reportRun = classfactory.reportRunClass(args);
reportRun.init();
reportRun.run();
reportRun.wait();
args.parmObject( args );
}

in the init method of your report try this:

public void init()
{
if( element.args() )
{
logId = element.args().parm();
}
super();
}

then you can use this parameter in your report form example:

public void executeSection()
{
;

if ( employee_1.LogId == logId)
{
emplId = employee_1.empId;
super();
}
if ( logid == "1")
{
emplId = DropHoliday_1.EmpId;
super();
}

}

Pass parameters between class and report +AX

Suppose that you have a RunBase class that call for a report .
You can use methods and parameters from this class into your report.
then in the init method of your report use this :

public void init()
{
// NoYes test;
super();
myCaller = this.args().caller();

if (myCaller)
{
if (myCaller.parmPayrollJobTable())
{
if(!myCaller.parmPayrollJobTable().PayrollClosed)
{
//BP Deviation Documented
payslipJour.setTmp();
//BP Deviation Documented
payslipTrans.setTmp();
payslipJour.setTmpData(myCaller.parmTmpPayslipJour());
payslipTrans.setTmpData(myCaller.parmTmpPayslipTrans());
thisEmplQueryRun = new QueryRun(myCaller.queryRun().query());
}
emplSet = myCaller.parmEmplSet();
}
}
else
{
throw error("@PAY3089");
}
}

15 Apr 2013

passing Args + ax 2012

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.

Create number sequence in D365 FO

Create the data type. Add code in the loadModule method of the appropriate NumberSeqModule subclass. Add a method to the module’s paramet...