Although we cannot use crossCompany keyword with delete_from command, we can still achieve the same functionality with some performance overhead as follows:
static void JobCCDel( Args _args )
Table21 tab21a, tab21b;
while select crossCompany minof(ratingNum), dataAreaId from tab21a
group by dataAreaId
tab21b = null;
where tab21b.ratingNum == tab21a.ratingNum;
Although we cannot use crossCompany keyword with update_recordset command, we can still acheive the same functionality with some performance overhead as follows:
static void JobCCForUpdMethod(Args _args)
while select forUpdate crossCompany countOfReviews from tab21
tab21.countOfReviews = tab21.countOfReviews + 2;
Although we cannot use crossCompany keyword with insert_recordset command, we can still achieve the same functionality with some performance overhead as follows:
static void JobCCIns(Args _args)
while select crossCompany actionDate, name, dataAreaId from tab21
where tab21.actionDate > str2Date('1998-01-22', 321)
tab22 = null;
tab22.actionDate = tab21.actionDate;
tab22.name = tab21.name;
AX developers always come across a requirement of showing data from different datasources on the same control though these datasources should be related to each other. The solution to this requirement is to define display methods on the table which you choose to be the control datasource. Display methods are very handy for showing data from related tables.
Consider for example the following tables:
If we need to show CustTable.AccountNum, DirPartyTable.Name and BankGroup.Name fields on the same control let’s say a grid control then we need to define the following display methods on CustTable if we have chosen CustTable as the grid’s datasource.
To retrieve DirPartyTable.Name
To retrieve BankGroup.Name
Now on the grid control, add two StringEdit controls to bind them with the display methods just defined above. Make sure to specify CustTable as the grid’s datasource. Also you must be setting DataMethod property of the StringEdit controls to the name of the respective display methods.
The result is awesome. You have one grid control showing data from different datasources!
Often we do not need to generate the next number sequence manually in X++ since creating records by using forms the system automatically handles number sequence generation by invoking Number Sequence Framework.
However, sometimes we need to generate number sequences manually in X++. The following code helps you to do that:
static void numberSequence(Args _args)
numberSeq = NumberSeq::newGetNum(SMAParameters::numRefSMAServiceObjectId());
serviceObjectTable.ServiceObjectId = numberSeq.num();
NumberSeq is the class in action here. Its static method newGetNum() takes NumberSequenceReference as an input parameter. All you need to do is to find the relevant number sequence reference in your case. Usually there are parm methods defined on Tables which give you the number sequence references.
Developers often need to change the current application object layer. For example, customizations in AX 2012 always take place in the USR layer. To change it:
1. Go to Microsoft Dynamics AX 2012 Configuration
2. Click Manage then click Create configuration
3. Give it a suitable name and then click OK
4. Switch to Developer tab and choose your desired layer from the drop down menu of Application object layer.
5. Click OK
If you are working on objects (Tables or Classes) you haven’t designed then it is quite possible you could have an insight about these objects by reverse engineering them to either data model or object model. I came to know about an excellent reverse engineering tool in AX 2012, that’s why sharing here for others.
First of all create an empty project and add the tables or classes to this project you want to reverse engineer.
Then right click the project node, click Add-Ins then click Reverse Engineer.
Select Visio UML data model or object model depending on the elements you have added to the project (Tables or Classes). Give appropriate path to save the Visio file to.
Reverse engineering starts. After the processing complets Visio open up automatically.
In Visio under Model Explorer you can find your project node under Top Package. You can find your tables in the relevant table group node. AX categories each table created. The default value of table group property is “Miscellaneous”. In my case all the tables can be found under Miscellaneous node.
Drag the tables to the drawing pane one by one and see how Visio renders table fields and relationships automatically.
Often AX tables contain more than 100 columns which results in a tedious data model in which relationships are hard to view. To only view the relationships and hide the columns, you can suppress table columns (attributes). Right click on the table, click Shape Display Options.
Check attributes under Suppress section to hide the attributes. In this way you can view the relationships easily!