static void curExtExample(Args _arg)
{
str curCompany;
;
// Sets curCompany to the extension of the current company.
curCompany= curExt();
print "Current extension is " + curCompany;
pause;
}
To Get the todays date in the Ax 2009 report write the following code in display method of the report
display public str ABC_TodaysDate()
{
return date2Str(today(), 123, DateDay::Digits2, DateSeparator::Slash, DateMonth::Digits2, DateSeparator::Slash, DateYear::Digits4);
}
thanks and your feedback will be appreciated
Note: You can pass only one Record with this Code, if you want to pass multiple grids,i will cover in next post.
Command | Description |
#define | Used to define a constant. |
AxExample: See macro HRMConstants. | |
Syntax: #define.myConstant100(’100′) | |
#if.empty | Will return true if the macro has not been called with the parameter validated in the statement. |
#if.notempty | Will return true if the macro has been called with the parameter validated in the statement. |
AxExample: See macro InventDimJoin | |
Syntax: #if.notempty(%3) print %3; #endif | |
#endif | Ends a #if.empty or a #if.notempty statement. |
AxExample: See macro InventDimJoin | |
Syntax: #endif (following any if statement) | |
#globalmacro | No difference whether declaring the start of a macro with #localmacro or #globalmacro. #globalmacro is not used in the standard package, consider using #localmacro instead. |
#localmacro | Specify the start of a local macro. |
AxExample: See macro BOM | |
Syntax: #localmacro.BOMDateSelect (((BOM.fromDate <= %1 || ! BOM.fromDate) && (BOM.toDate >= %1 || ! BOM.toDate)) || ! %1 ) #endmacro | |
#endmacro | Ends a #LOCALMACRO or a #GLOBALMACRO. |
#linenumber | Returns the current line number of the macro. Can be used while debugging, but not of must use. |
#macrolib | Used to load an AOT macro from code. |
AxExample: See class method BOMHierarchy.searchDownBOM() | |
Syntax: #macrolib.MyMacro | |
#undef | Undefine a constant declared with #DEFINE. A defined constant cannot be used if #undef is called with the define name. |
Syntax: #define.MyConstant(100) print #MyConstant; #undef.MyConstant print #MyConstant; // will fail, as #MyConstant is not defined. |
| Keyword | Example |
| asc | Set the sorting order to ascending. All selects are default fetching data ascending. |
| Syntax: select custTable order by accountNum asc; | |
| desc | Set the sorting order to descending. Used in combination with order by or group by. |
| Syntax: select custTable order by name desc; | |
| AX Example: See table method CustTable.lastPayment(). | |
| avg | Select uses aggregate keyword (avg) using only one call to the database calculating a result based on multiple records |
| Syntax: select avg(amountMST) from custTrans; | |
| AX Example: See class method KMKnowledgeCollectorStatisticsExecute.runQuery(). | |
| count | Aggregate keyword used to count the number of records fetched. |
| Syntax: select count(recId) from custTrans; | |
| AX Example: See class method KMKnowledgeCollectorStatisticsExecute.runQuery(). | |
| sum | Aggregate keyword used to sum values of a field fetched. |
| Syntax: select sum(amountMST) from custTrans; | |
| AX Example: See class method KMKnowledgeCollectorStatisticsExecute.runQuery(). | |
| maxof | Aggregate keyword used to return the highest field value fetched |
| Syntax: select maxOf(amountMST) from custTrans; | |
| AX Example: See class method KMKnowledgeCollectorStatisticsExecute.runQuery(). | |
| minof | Aggregate keyword used to return the lowest field value fetched. |
| Syntax: select minOf(amountMST) from custTrans; | |
| AX Example: See class method KMKnowledgeCollectorStatisticsExecute.runQuery(). | |
| delete_from | Will delete multiple records in one call to the database. |
| Syntax: delete_from myTable where myTable.amountMST <=’1000′; | |
| AX Example: See class method InventCostCleanUp.updateDelSettlement(). | |
| exists join | Exists join is used to fetch records where at least one record in the secondary table matches the join expression. No records will be fetched from the secondary table using exists join. |
| Syntax: while select custTable exists join custTrans where custTable.accountNum == custTrans.accountNum | |
| AX Example: See class method InventAdj_Cancel.cancelInventSettlements(). | |
| notexists join | Opposite of exists join. Will fetch records from the primary table, where no records in the secondary table match the join expression. |
| Syntax: while select custTable notexists join custTrans where custTable.accountNum == custTrans.accountNum | |
| AX Example: See class method InventConsistencyCheck_Trans.run(). | |
| outer join | Outer join will select records from both tables regardless if there are any records in the secondary table matching the join expression. |
| Syntax: while select custTable outer join custTrans | |
| AX Example: See class method SysHelpStatistics.doTeams(). | |
| join | Join will fetch Records matching the join expressionfrom both tables. (innerjoin) |
| Syntax: while select custTable join custTrans where custTable.accountNum == custTrans.accountNum | |
| AX Example: See table method SalesTable.LastConfirm(). | |
| firstfast | Instruct to select the first record faster. used in situations where only one record is shown, like in a dialog. |
| Syntax: select firstfast custTable order by accountNum; | |
| AX Example: See class method ProjPeriodCreatePeriod.dialog(). | |
| firstonly | First record will be selected. Firstonly should always be used when not using while in selects. |
| Syntax: select firstonly custTable where custTable.AccountNum == _custAccount (variable) | |
| AX Example: See Table method CustTable.find(). | |
| forupdate | Used If records in a select are to be updated |
| Syntax: while select forupdate reqTransBOM where reqTransBOM.ReqPlanId == this.ReqPlanId | |
| AX Example: See Table method ReqTrans.deleteExplosionCoverage(). | |
| from | Default all fields of a table is selected. From is used to select only the fields specified. Use it for optimization only, as it makes the code more complex. |
| Syntax: select accountNum, name from custTable; | |
| group by | Sort the fetched data group by the fields specified. Only the fields specified in the group by will be fetched. |
| Syntax: while select custTable group by custGroup; | |
| AX Example: See class method InventStatisticsUS.calcTotals(). | |
| index | Used to set the sorting order of the fetched data. The kernel will convert the keyword index to an order by using the fields from the index. Index should only be used if the fetched data must be sorted in a specific way, as the database will choose a proper index. |
| Syntax: while select custTable index accountIdx. | |
| index hint | Index hint will force the database to use the specified index. |
| Syntax: while select custTable index hint accountIdx. | |
| AX Example: See Table method ReqTrans.deleteExplosionCoverage(). | |
| insert_recordset | Used to insert multiple records in a table. Insert_recordset is useful when copying data from one table to another as it only requires one call to the database |
| Syntax: insert_recordset myTable (myNum,mySum) select myNum, sum(myValue) from anotherTable group by myNum where myNum <= 100; | |
| AX Example: See class method SysLicenseCodeReadFile.handleDomainLicenseChanges(). | |
| update_recordset | Used to update multiple records in one database call. Useful to initialize fields in a fast way. The fields updated are specified after thekeyword setting. |
| Syntax: update_recordset myTable setting field1 = myTable.field1 * 1.10; | |
| AX Example: See class method ProdUpdHistoricalCost.postScrap(). | |
Caller | Gets or sets the instance of the object that created this instance of the Args class. |
name | Gets and sets the name of the application object to call. |
parm | Gets or sets a string that specifies miscellaneous information for the called object. |
parmEnum | Gets or sets the enumeration value of the enumeration type that is specified in the parmEnumType method. |
parmEnmType | Gets or sets the ID value of any enumeration type. |
ParmObject | Gets or sets an instance of any object to pass to the called object. |
record | Gets and sets the record from the table on which the caller object is working. |
void clicked()
{
// Args class is usually used in Axapta for passing parameters between forms
Args args;
FormRun formRun;
// Our custom made class for passing complex set of parameters
FormBParams formBParams = new FormBParams();
Array items = new Array( Types::String );
int i;
;
args = new args();
// Our values which we want to pass to FormB
// If we want pass just simple string we can use 'parm' method of 'Args' class
args.parm( strValue.text() );
// We also can pass enum value to FormB
args.parmEnum( NoYesEnumValue.selection() );
args.parmEnumType( EnumNum( NoYes ) );
// and also can pass a cursor pointing to some record (in our case it is EmplTable )
args.record( EmplTable );
// If we want pass more complex set of parameters we can develop our own class
// just for passing our parameters.
formBParams.parmSomeDate( someDate.dateValue() );
formBParams.parmSomeTime( someTime.value() );
for( i=0; i<ListBox.items(); i++ )
{
items.value( i+1, ListBox.getText( i ) );
}
formBParams.parmItems( items );
// Pass our object to FormB
args.parmObject( formBParams );
// Run FormB
args.name( formstr( FormB ) );
formRun = classFactory.formRunClass( Args );
formRun.init();
formrun.run();
formrun.wait();
if( formrun.closedOk() )
{
answerFromFormB.text( args.parm() );
}
super();
}
public void init()
{
EmplTable emplTableRecord;
FormBParams formBParams;
Array items;
int i;
;
super();
// Check for passed arguments
if( element.args() )
{
// get string parameter
strValue.text( element.args().parm() );
// get enum parameter
if( element.args().parmEnumType() == EnumNum( NoYes ) )
{
NoYesEnumValue.selection( element.args().parmEnum() );
}
// get object parameter
if( element.args().parmObject() )
{
formBParams = element.args().parmObject();
items = formBParams.parmItems();
for( i=1; i<=items.lastIndex(); i++ )
{
ListBox.add( items.value(i) );
}
someDate.dateValue( formBParams.parmSomeDate() );
someTime.value( formBParams.parmSomeTime() );
}
// get record parameter
if( element.args().record() && element.args().record().TableId == TableNum( EmplTable ) )
{
emplTableRecord = element.args().record();
emplName.text( emplTableRecord.Name );
}
}
}
void clicked()
{
super();
element.args().parm( strAnswer.text() );
element.closeOk();
}
void clicked()
{
// Args class is usually used in Axapta for passing parameters between forms
Args args;
FormRun formRun;
// Our custom made class for passing complex set of parameters
FormBParams formBParams = new FormBParams();
Array items = new Array( Types::String );
int i;
;
args = new args();
// Our values which we want to pass to FormB
// If we want pass just simple string we can use 'parm' method of 'Args' class
args.parm( strValue.text() );
// We also can pass enum value to FormB
args.parmEnum( NoYesEnumValue.selection() );
args.parmEnumType( EnumNum( NoYes ) );
// and also can pass a cursor pointing to some record (in our case it is EmplTable )
args.record( EmplTable );
// If we want pass more complex set of parameters we can develop our own class
// just for passing our parameters.
formBParams.parmSomeDate( someDate.dateValue() );
formBParams.parmSomeTime( someTime.value() );
for( i=0; i<ListBox.items(); i++ )
{
items.value( i+1, ListBox.getText( i ) );
}
formBParams.parmItems( items );
// Pass our object to FormB
args.parmObject( formBParams );
// Run FormB
args.name( formstr( FormB ) );
formRun = classFactory.formRunClass( Args );
formRun.init();
formrun.run();
formrun.wait();
if( formrun.closedOk() )
{
answerFromFormB.text( args.parm() );
}
super();
}
public void init()
{
EmplTable emplTableRecord;
FormBParams formBParams;
Array items;
int i;
;
super();
// Check for passed arguments
if( element.args() )
{
// get string parameter
strValue.text( element.args().parm() );
// get enum parameter
if( element.args().parmEnumType() == EnumNum( NoYes ) )
{
NoYesEnumValue.selection( element.args().parmEnum() );
}
// get object parameter
if( element.args().parmObject() )
{
formBParams = element.args().parmObject();
items = formBParams.parmItems();
for( i=1; i<=items.lastIndex(); i++ )
{
ListBox.add( items.value(i) );
}
someDate.dateValue( formBParams.parmSomeDate() );
someTime.value( formBParams.parmSomeTime() );
}
// get record parameter
if( element.args().record() && element.args().record().TableId == TableNum( EmplTable ) )
{
emplTableRecord = element.args().record();
emplName.text( emplTableRecord.Name );
}
}
}
void clicked()
{
super();
element.args().parm( strAnswer.text() );
element.closeOk();
}