SysOperationFramework : Field display order

December 9th, 2011 No comments

Since the arrival of Dynamics Ax 2012, the traditional RunBaseBatch framework is getting obsolete. This has been replaced by the SysOperationFramework. This framework brings a few nice features that were missing in the RunBaseBatch framework. One them is the MVC pattern to separate concerns.

The basics

I would like to start with a few links concerning how to create SysOperationFramework services. A colleague of mine, Klaas Deforce, has created some posts that clearly explain how it works.

All of the post are linked through this overview post : http://www.artofcreation.be/2011/08/21/ax2012-sysoperation-introduction/

Field display order

Well now, let’s come to the question of this post : How can you determine the sequence of dialog fields on the dialogs created by the SysOperationFramework? The answer here lies in the Attributes available also in Dynamics Ax 2012. You have a contract with several datamembers marked with the [DataMemberAttribute] attribute. To determine the sequence you can add the [SysOperationDisplayOrderAttribute] attribute (http://msdn.microsoft.com/en-us/library/gg963068.aspx).

For an example of this, you can check the AssetBalanceReportColumnsContract class, method parmAssetBookId.

[
    DataMemberAttribute('AssetBookId'),
    SysOperationGroupMemberAttribute('Book'),
    SysOperationDisplayOrderAttribute('1')
]
public AssetBookMergeId parmAssetBookId(AssetBookMergeId _assetBookId = assetBookId)
{
    assetBookId = _assetBookId;
    return assetBookId;
}

Groups and group sequence

In the previous sample of code you can also see the SysOperationGroupMemberAttribute attribute. This is to determine which fields belong to a certain group on a dialog. And you can also use a custom sequence on groups by using the SysOperationGroupAttribute attribute as seen in the classDeclaration:

[
    DataContractAttribute,
    SysOperationGroupAttribute('Book', "@SYS95794", '1'),
    SysOperationGroupAttribute('Period', "@SYS40", '2')
]
public class AssetBalanceReportColumnsContract implements SysOperationValidatable
{
    boolean visibleFR;
    AssetBookMergeId assetBookId;
    ToDate closingDatePriorYear;
    ToDate closingDateThisYear;
}

So there you have it. If you want to rearrange things on the dialog, you can use the above method.

 

Propagate infolog messages to the windows event log

November 4th, 2011 No comments

The windows event viewer can be a nice tool to check for messages dispatched by the system. You can save the logs in there, reopen them, different kinds of information is available so you can actually trace lots of things in there. But wouldn’t it be nice to also be able to log the messages thrown by Ax 2012 in the windows event log?

That way you do not lose user messages and they are nicely logged into the event viewer. It can also help to log messages received on a client that you cannot seem to reproduce, …

Well, it is possible and here is how to do it in a couple of steps:

  • Add a windows event log and source to put our specific infolog messages in
  • Edit the Ax32 config file to add an event log listener to the configuration

Create event log and source

So first things first, let’s create a windows event log by using the following powershell command

new-eventlog -logname "RealDolmen Ax Solutions" -source "Ax 2012 Infolog"

The result should be like in the figure below

Configure the listener

To add a listener, first open the ax32.exe.config file located in the client\bin directory. You should see a configuration similar to this:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup useLegacyV2RuntimeActivationPolicy="true">
<supportedRuntime version="v4.0.30319" />
<requiredRuntime version="v4.0.30319" safemode="true"/>
</startup>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<probing privatePath="EditorComponents"/>
</assemblyBinding>
</runtime>
</configuration>

Modify the configuration so that it looks like this: (It is absolutely important to keep the source name !! The initializeData must be filled with the source you created in the event log)

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.diagnostics>
<trace autoflush="true"/>
<sources>
<source name="Microsoft.Dynamics.Kernel.Client.DiagnosticLog-Infolog" switchValue="Information">
<listeners>
<!-- The initializeData contains the source that was linked to the created event log -->
<add name="EventLog"
type="System.Diagnostics.EventLogTraceListener"
initializeData="Ax 2012 Infolog"/>
</listeners>
</source>
</sources>
</system.diagnostics>
<startup useLegacyV2RuntimeActivationPolicy="true">
<supportedRuntime version="v4.0.30319" />
<requiredRuntime version="v4.0.30319" safemode="true"/>
</startup>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<probing privatePath="EditorComponents"/>
</assemblyBinding>
</runtime>
</configuration>

Now we are all set up and when firing up the client, any messages to the infolog should be redirected to the event log. So let’s send some error lines to the infolog.

Now check if the same messages appear in the infolog. Normally this is what it should look like:

So there you have it. The messages are nicely logged in the event viewer. As a last remark, you can also adjust the logging level by modifying the switchvalue of the source. Off will not log anything at all, verbose will fill your event log with everything.

AX2012 Editor Extensions

November 3rd, 2011 No comments

Today I was reading a very interesting post about possible extensions to the editor in AX 2012 and I would very much like to share it.

Basically it explains that the editor is a hosted visual studio editor (that was already clear) and by knowing this, it is also possible to use the extensions that are available there to the editor inside Ax.
The post I read was dealing with the brace matching extension that is available to do automatic formatting of the braces.

You can read the full post here : http://dev.goshoom.net/en/2011/10/ax2012-editor-extensions/

Client acces log

October 16th, 2011 No comments

I’ve recently read a post on the performance team blog and I found it interesting so I’m posting the link again here.

http://blogs.msdn.com/b/axperf/archive/2011/10/14/client-access-log-dynamics-ax-2012.aspx

The blog post explains how to track user activity within the system.

 

AX 2012 Navigation Properties

September 7th, 2011 1 comment

It’s been a while since I’ve posted, but here’s a small little post about what I think is a cool feature in Ax 2012!

In AX2009, when you have a table that has a relation to another table and you want to use it in code, you have to provide a method that performs a select on the other table and returned the related record. ( fe : SalesTable.SalesLine() ) Well this is something cool in AX2012. Here’s how you can do it now.

On the main table you have the relationship. There you can use a new property called CreateNavigationPropertyMethods and set it to Yes.

Once you have done this, there will be a method on you table that returns the related record.

 

SQL Server : Change TempDB location

April 21st, 2011 No comments
This is no rocket science but today I needed to move the tempDB to another disk. This is something I though could be done by changing the location path on the database properties in the files tab. Well, bummer, the location was not editable there. So how can we do this… ?
Running this query will solve this for you :
USE
master;
GO
ALTER DATABASE tempdb
MODIFY FILE (NAME = tempdev, FILENAME = ‘F:\MSSQL\Data\tempdb.mdf’);
GO
ALTER DATABASE tempdb
MODIFY FILE (NAME = templog, FILENAME = ‘F:\MSSQL\Data\templog.ldf’);
GO

Performance in Dynamics Ax 2012

January 20th, 2011 1 comment

Today I attended what I think was the most interesting session of the conference for me. (There will be one about AIF today but I think this will not as interesting as what I learned about performance)

Basically what they did can be devided in these categories :

  • Scale up and scale out on AOSs and Clients
  • Utilize more SQL features
  • Application effeciency
  • World class diagnosis tools

SysGlobalObjectCache

The first part was about caching. They added a global cache but this time the cache is also available across sessions.
The cache also get syncronised between the AOS instances, but there is a short delay on this, so you never really can trust that the cache is identically on the other AOS Instances.

As to when the objects in the cache are cleared, there are two main triggers for deleting an object from the cache:

  • The limit of number of objects is reached (to be found in the SysGlobalConfiguration table on SQL Server
  • The developer deletes / overwrites the object in the cache

TraceParser

Before the trace parser was a tool to be installed additionally to Ax but now it is part of the system. There are a few ways in which you can use the trace parser:

  • By starting up the performance cockpit from the tools menu
  • By using it to code by starting and stopping trace and specifying a file to log to.

So this time it is actually much more stable and reliable to use. Actually now it is so easy that each developer should develop with the trace parser next to him at all times to keep performance in mind from the beginning.

Data Access : Ad Hoc mode

When your X++ query is getting too big, then use Ad Hoc mode. Here you would actually only select the fields you need.
Also, set the dynamics property on the query fields to false and set OnlyFetchActive to true on the FormDataSource

By selecting only the things you need, the kernel will not join all the tables in the table hierarchy but also the inherited tables where you need fields from.

SQL TempTable

In the AOT, you can now set the TableType on a table object to one of the following :

  • InMemory (The old in memory temp table)
  • Regular (Non temporary table)
  • TempDB (SQL Server tempDB table)

SysOperation

Here I can be brief (because the white paper about this is going to follow later on)

Basically the RunBase framework is now only there for backward compatibility! So now the new SysOperation framework will be used.
This is residing in the AOS also, but more on that when I have a clearer view on this.

So this is what I could capture from the session. Probably missed a lot of other stuff too but for that, we will have the video’s J

Dynamics Ax 2012 Technical conference : Day 1 : Part 1

January 19th, 2011 6 comments

This articles will be brief, because I don’t have much time between the sessions J

Yesterdag was the first day of the Dynamics Technical conference and following sessions were attended by me:

  • Programming model improvements Part 1 of 2
  • Programming model improvements Part 2 of 2
  • Developing in .NET managed code and X++ Enhancements
  • Solving the element ID problem

Programming model improvements Part 1 of 2

From this session, I remember the following additional features:

  • Table inheritance is added. So now you can have abstract tables which are then inherited by child tables.
    The unit of work pattern also comes into play here as there will be issues to address to manage transactions and code dealing with one ‘virtual record’ which may consist of multiple child tables. (Vehicle table with child tables bycicle, car, truck, …)
  • Next to normal X++ temporary tables, there is now also support for temporary tables in SQL Server
  • Date effective tables have been added. This means you can actualy filter records based on an ‘effective as of date’
  • Eventing has been added so now you can actually subscribe methods to events on other classes. Also, this is implemented by drag and drop so it is actually user friendly to do this.
  • The normal batch framework has been ‘adjusted / replaced’ with the SysOperation framework
  • The tree of linked tables are then linked by RecId, but you can actually have a key with fields specified in a field group to be used in the design when showing on what the linked was based
  • Tables have full text indes support now : This means they can be optimized for searches on text fields to look for certain words in the body.

Historical data pattern

This one is actually cool. Let’s say you have a historical table to contain a history of sales. Then you can set properties on the SalesTable datasource and the kernel will keep the history for you. So when you change values on the sales order for example, the kernel will create / update records in the historical data table.

Query ranges vs Query filters

When using joins (outer joins) the query ranges can produce incorrect outcomes. But now query filters are used to fix that. Instead of using the QueryRange object on the query, you can now also use QueryFilter objects and they are more optimized for SQL Server.

The other sessions will be describes in following posts as there is new session beginning right now J

IDMF Post Installation Issue : ODBC Connection

December 22nd, 2010 No comments

After the installation of the IDMF there are some post installation steps to do. One of them is to populate the IDMF Management database with data from the Cross Reference.

To do this, some job has to be run on the production database that makes connection to the IDMF database by ODBC. When I tried to do this I get the error that the connection failed. Therefor I have made a little change to the classes responsible for the population.

The DMTPopulateManagementDB\createConnection method is altered to work with a DSN (for some reason it did not work for me if not using a DSN) (And please don’t mind the hard coded name J)

For this to work, we need to create a system DSN on Windows to point to the SQL Server database. So we create one:

But there is one issue here: On a 64-bit 2008 Server, the dynamics client will not find the 64-bit DSN created, so we have to start the 32 bit version of the ODBC Tool.

When the 32 bit DSN is created, it worked for me.

AIF: Service actions lost after recreating service

November 16th, 2010 4 comments

When you delete service objects (classes, macros, service node…) and recreate the service you may have run into the issue that none of the service operations were visible.
Here’s how I solved it today when having the same issue. (We had to remove everything or else the problem was not solved)  

The problem is that the actions are not gone, but they were linked incorrectly. The AIFAction table contains the operations and also contains the classId of the class where the methods to handle the actions are.  

  

Well as the service objects were deleted and afterwards recreated, the class ID of the service class had been altered. Due to this changed ID, none of the operations were visible on the service.  

To fix this, just delete the current records in the AIFAction table for the corresponding service and then we can recreate the actions by calling the AIFServiceGenerationManager class,
method RegisterService.  

AIFServiceGenerationManager::registerService("NVMPPointBalanceService");

Then we can see the operations again in the services form.