31 August 2012

Best Practise Error: different origin value on a new object

I just got thie Best Pracitse Error on a newly created table in Dynamics AX 2012:

The element has an origin value that is different from the origin value in a previous version of Microsoft  Dynamics AX. 

Checks that the element had the same origin value in earlier versions of Microsoft Dynamics AX. The origin value is the beginning value of the element. This check was added due to the changes regarding installation specific IDs. 
BPErrorObjectOriginMismatch @SYS335100

I was confused about this message, cause it doesn't make any sence for new objects. After a restart of the AOS the error is gone.

30 August 2012

Set up AX 2012 to support workflows

Set up workflows in Dynamics AX 2012

Important steps to check:
  • System Administration 
    • Setup 
      • System
        • Server configuration:
          check that there is only the AOS instance that is required
          acitvate the "is batch server" flag
        • System Service Accounts
          check the Workflow execution account
      • Workflow
        • Workflow infrastructure configuration
          Click through the wizard to set up the requiered batch jobs
  • Also don't forget that workflows require CIL. So full CIL generation should be done.

Book: Inside Microsoft Dynamics AX 2012

The Book "Inside Microsoft Dynamics AX 2012" is ready for pre order at amazon.

29 August 2012

CIL Generation problems

Lately i had some trouble generating CIL. I got some Errors in standard Classes like Retail and SysQuery.

CIL-Generierung: Error 1. Class: SysQuery, Method: queryAddStaticCursorAsRangeAndValue, Exception: System.ArgumentException: Type QueryBuildStaticlink was not found in the CIL that was generated from X++.

\Classes\RetailStatementPostSalesOrders\createAggregatedSaleLines Err: 351 \Classes\RetailStatementPostSalesOrders\createSalesOrders Err: 351

These errors are logged in the CIL generation log file which is stored in the folder:
C:\Program Files\Microsoft Dynamics AX\60\Server\MicrosoftDynamicsAX\bin\XppIL with the name Dynamics.Ax.Application.dll.log

To get rid of the sysQuery error the following steps did the trick:
  1. Compile SysQuery Class 
  2. Start Full CIL Generation 
When these steps doesn't solve the problem another option is to deleter CIL Files and restart Full CiL:

  1. Stop the AOS
  2. Delete files in this folder C:\Program Files\Microsoft Dynamics AX\60\Server\MicrosoftDynamicsAX\bin\XppIL\source
  3. Start the AOS again
  4. Start full CIL generation

21 August 2012

Difference between two dates in days

To get the difference between two dates in dynamics ax just convert the dates into numbers and subtract one from the other. The result would be the amount of days between these dates.

days = date2num(Date123) - date2num(Date234);

To get the difference between two DateTime Values just use the DateTimeUtil Class. The result is the difference in seconds. So just divide these through #secondsPerDay and you'll get the days


days = DateTimeutil::getDifference(DateTime123, DateTime234) / #secondsPerDay;

26 July 2012

AX 2012 view and edit mode

To find out if an AX 2012 form is in view or edit mode just call:


To catch the event of changing the mode you have to override the task() method of the form and check the value of the _taskId.

public int task(int _taskId) 

    int ret;

    ret = super(_taskId); 

    if (_taskId == #taskEditRecord) 
        info("edit or view mode?"); 

    return ret; 

25 July 2012

Calling a MenuItem

This post is just for me to remeber these lines of code ;)

MenuFunction menuFunction = new MenuFunction(menuitemdisplaystr(MENUITEM), MenuItemType::Display); 
Args args = new Args(); 


24 July 2012

Dynamics AX BaseEnums in SSRS Reports

In SSRS AX BaseEnums are represented by two fields in the DataSet

Normally there is one with the "name" of the BaseEnum that represents the name of the element and another one called "name1" that contains the label of the element. In some cases this is switched around. So that "name" contains the label and "name1" contains the name of the element.
The only way to notice that is to have a look at the Alias. There you can see LABEL or NAME.

23 July 2012

How to sign a Dynamics AX model file

To sign a model file you need an SNK file. If you don't have one just generate a key pair with the following command:

C:\Program Files\Microsoft SDKs\Windows\v7.0A\Bin\sn.exe -k YOURKEYFILE.snk
/(in older Versions it also could be in v6.0A) 

After that the snk file can be used to sign the model that is exported from an AOS. Make sure to set the client config to the right AOS and than just use the following command:

AxUtil export /model:NAMEOFTHEMODEL /file:MODEL.axmodel /key: YOURKEYFILE.snk

19 June 2012

VisualStudio Message - .NetFramework.Version=v4.0 Profile Full

When this message apperas during upgrade of a VisualStudio 2008 project to VisualStudio 2010. Just open the .csproj file in an editor and remove the line:

11 June 2012

AXUtil and Powershell

just to remeber the right syntax:

Import Model:
axutil import /file:abc.axmodel /conflict:push /config:AOSname

Delete Layer:
axutil delete /layer:usr /config:AOSname
instead of /config: it is possible to use the dbName /db:DBname 

Uninstall-AXModel -Database "NameOfDB" -Model "NameOfModel"

05 June 2012

SSRS Report: Display Image from Database

To display an image from DynamicsAX in an SSRS report the easiest way is to add an EDT that Extends the Bitmap EDT to the tmp table for the report. In the Dataprovider just add the image to the tmp table (for further information about image handling in ax check the image class).
Than add an image object onto the report design and set the properties. Select the right MIME-Type and try it!

19 April 2012

Add a single postal location to an ax 2012 form

To add a single postal address to a form with the new ActionPane there are several steps to do:

  1. Add the EDT LogisticsLocationRecId to the table where the new postalAddress should be added
  2. Add this table to the LogisticsLocationMap and create a Mapping: LogisticsLocationMap.Location ==  theNewTable.LogsticsLocationRecId
  3. Add the LogisticsPostalAddress Table to the Form

  4. Paste the following code to the form:

    public class FormRun extends ObjectRun
        LogisticsPostalAddressFormHandler  addressController;

    public void init()

            addressController =
        LogisticsPostalAddressFormHandler::newParameters(newTable_ds, logisticsPostalAddress_ds);

              addressController.callerUpdateQuery(fieldNum(newTable, LogisticsLocationRecId));

          public LogisticsPostalAddressFormHandler getAddressController()
              return addressController;
        1. Place an ActionPane to your form with the MenuItemButtons New/Edit/Clear/Map.
          The easiest way to do this is to copy and paste it from the BankAccountTable form.

        2. Add this Code to the active method of the main DS:

          public int active()
              int ret;

              ret = super();

              if (ret)
                  addressController.callerUpdateButtons(newAddress, editAddress, clearAddress, mapButton);

              return ret;
        3. after that synchronize table and map and than try to open the form ;)

        11 April 2012

        Problems with ordering grid columns

        If there are problems with the ordering of grid columns of a grid inside a tab although the AllowUserSetup of the form is set to Yes. Check if the method tabChanged of the tab control is overwritten. Overwriting this method can cause problems with the re-ordering.
        Instead of using the TabChanged on the tab control move the code to the pageActivated method of the TabPage.

        23 March 2012

        Grouping data in SSRS

        To group data on a report you need the grouping pane. If it is not visible click grouping on the view tab.
        In the grouping pane right click a group an select add before or after to specify where to add the group. This group dialog opens:

        Set the name of the group in this dialog. After that the group expression can be specified. Just add grouping criterias. It is possible to group by data fields or by expressions.
        When closing the dialog a new grouping pane is added to the tablix data region. it contains a row or column where group values can be displayed.

        22 March 2012

        Fast way to refresh args caller datasource

        Cause I always forget these two lines of code to research the datasource of the calling args record in Dynamics AX. I will post it here so that I can google it every time I need it ;)

        FormDataSource   callerDataSource;

        if (_args != null
            && _args.record() != null)
            callerDataSource = _args.record().dataSource();

        21 March 2012

        Adding an AX table as Dataset to an SSRS Report

        It is important to add the following code in the processReport Method of the DataProvider class in Dynamics AX to use a Table as a new Dataset in an SSRS Report:


        12 March 2012

        HTML Tags that can be used in SSRS

        To use HTML to format text in SSRS it is important to change the placeholder properties (right click on to the placeholder). In the placeholder properties change the markup type to HTML.

        After that it is possible to format text with HTML Tags. The following list of HTML Tags shows possible Tags that can be used in an SSRS control:
        • Hyperlinks: <A href>
        • Fonts: <FONT>
        • Header, style and block elements: <H{n}>, <DIV>, <SPAN>,<P>, <DIV>, <LI>, <HN>
        • Text format: <B>, <I>, <U>, <S>
        • List handling: <OL>, <UL>, <LI>
        For further information check out the following MSDN Page about Formatting Text and importing HTML.

        03 February 2012

        02 February 2012

        Change SSRS Report to orientation to landscape

        If you need to change the orientation of a report to landscape or to a different format like letter or DIN A4 there is a real easy way. But you'll have to know this way :)

        Right click on the background beside the report and select report properties. (or in german: Berichtseigenschaften...)

        Than the following form opens where it's possible to change the orientation, the size and so on...

        26 January 2012

        SSRS Insert new field error - field token is invalid

        If you get this error message:

        Field token Fields!MyNewField.Value is invalid. Could not find the identifier. \SSRS\Reports\Reports\

        when you try to add a new field from AX to a SSRS Report.

        The first thing to do is to refresh the datasets in VisualStudio.

        After that you should check the Query property of the DS. If there is a fieldlist in the select statement. Just click into the property and open the "Select a Microsoft Dynamics AX Report Data Provider" Dialog. Select the required DataProvider Class and click Next. Than you'll get the possibility to select some or all fields from the tables that are provided by the DP class.

        11 January 2012

        Open Visual Studio with another AX configuration

        If you need to start Visual Studio connected to another AOS there are two ways to do this:

        1. Create a shortcut:

          add the/AxConfig command in the Target field:
          "C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\devenv.exe" /AxConfig NameOfClientConfig
          "C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\devenv.exe" /AxConfig C:\AX2012ClientConfig\ClientConfig.axc
        2. CommandLine:
        3. you can use the commands as shown above.

        05 January 2012

        Test Dynamics AX 2012 SSRS Report Server Configuration

        To check you're SSRS Configuration open a Microsoft Dynamics AX 2012 Management Shell as an admin and insert the following command:


        If you want to run the test against a special ReportServer:

        Test-AXReportServerConfiguration -Id ReportServer01

        Or to check a special WSDL Port

        Test-AXReportServerConfiguration -ServicesAOSName ServerName
        -ServicesAOSWSDLPort 8103

        04 January 2012

        Deploy Dynamics AX 2012 default SSRS reports

        If you get the following error message while trying to open a standard report in Dynamics AX 2012:

        Error while setting server report parameters. Error message: Das /DynamicsAX/StaticReports/en-US/SalesInvoice.Report-Element wurde nicht gefunden. (rsItemNotFound)

        The first thing to check are the reportServer Settings in AX: System administration -> Setup -> Business Inteligence -> Reporting Services -> Report Server

        Click Validate Settings to find out if the parameters are set correctly. If this succeeds Ax is set up correct and you'll only have to deploy the AX Reports to the SSRS Server. Therefor you need to open an instance of the Microsoft Dynamics AX 2012 Management Shell (run as Administrator).  
        In the PowerShell window you can use the following command:

        Publish-AXReport -ReportName * 

        or to publish just one Report

        Publish-AXReport -ReportName NameOfTheReport 
        when having problems with user permissions one solution could be the parameter -skipReportServerAdminCheck.
        Microsoft said: Actually the code inside axutil is trying to make a check for the user’s permissions – and it is the check itself that needs higher permissions (it’s looking into Active Directory). So the problem is that the user does not have enough rights to make the check in Active Directory, but they would have enough to actually deploy reports
        Publish-AXReport -ReportName NameOfTheReport -skipReportServerAdminCheck

        If you want to deploy Reports from the AOT it's recommended to start the AX as an Administrator