Microsoft Dynamics NAV

Team Blog

  • Microsoft Dynamics NAV Team Blog

    Coming Soon: Enabling Commerce Gateway for Microsoft Dynamics NAV 2013


    With Commerce Gateway for Microsoft Dynamics NAV, companies can use Microsoft Dynamics NAV to electronically exchange trading documents with business partners regardless of conversion requirements and data formats. This helps streamline business processes and reduce transaction costs. Commerce Gateway also makes it easier for companies to meet the changing demands of their trading partners, regardless of the industry they are in, the system that they use, or the standards that their partners require.

    As some of you may have noticed, Microsoft Dynamics NAV 2013 shipped without Commerce Gateway. We have explored a number of different options for enabling Commerce Gateway. This blog post describes the recommended upgrade path for users of Commerce Gateway to make their solution compatible with Microsoft Dynamics NAV 2013.

    We are currently working on a sample application that will demonstrate how to upgrade the Commerce Gateway solution. The sample will show how you should set up the connection between Microsoft BizTalk and Microsoft Dynamics NAV using a web service. The sample will be shipped through the hotfix process, after it has been through testing. For now, we expect to release the sample at the end of March.

    New customers that need Commerce Gateway will have to upgrade their solutions from Microsoft Dynamics NAV 2009 to Microsoft Dynamics NAV 2013. For more information, see Upgrading to Microsoft Dynamics NAV 2013.

    Commerce Gateway is still included in the license as part of the product and can be purchased as normal.

    Architectural changes

    In architectural terms, the Commerce Gateway solution consists of an application part, a communication part, and a BizTalk part. The communication part is the part that requires the most changes to be able to run with Microsoft Dynamics NAV 2013. We recommend that you change the communication part to use a web service connection instead of using the Request Client and the Request Server. For this to work, it is also required that you make a few changes to the Microsoft BizTalk configuration. There are minor changes to the application part.

    The main reason changes to Commerce Gateway were required for it to work on Microsoft Dynamics NAV 2013 are the architectural changes that were introduced with this version, such as the 64-bit Microsoft Dynamics NAV Server, as well as the removal of COM support on the server. Both changes require a change in the Commerce Gateway implementation, since it relies on a 32-bit COM implementation for the Request Server and the Request Client.

    Summary of recommended changes

    1. Upgrade application code to Microsoft Dynamics NAV 2013. The application code is impacted by the removal of support for forms.
    2. Change the connection between the Microsoft BizTalk server and Microsoft Dynamics NAV 2013 to use a new web service, which will be defined in the sample. Changing your solution to use web services will simplify the Microsoft Dynamics NAV 2013 installation, as you will no longer be required to use the Commerce Gateway Request server and the Commerce Gateway Request Client.
    3. The Microsoft Dynamics NAV 2013 architecture does not allow the use of automation on the server. Consequently, we have changed five objects to use the .NET Framework XML Document Object Model (DOM). You will have to upgrade your solution to merge in these changes.
    4. Change the connection setup on the Microsoft BizTalk Server to use the web service. You will need to create a new Send port and to reconfigure the orchestrations.

    All of the above changes will be described and implemented in the code sample that will ship at the end of March.


    Rikke Lassen

    Senior Program Manager

  • Microsoft Dynamics NAV Team Blog

    Transfooter and Transheader functionality in RDLC(SSRS) reports - revisited


    In one of our previous blog post we discussed the possibility to do Transfooter and Transheader functionality in RDLC(SSRS) reports and describes a viable solution for this in RDLC.

    In this blog post we would like to suggest an alternative, a bit more economical and easier to implement solution for the same problem.

    For the demo we use the same table and the same report and will strive to achieve the same results as in the mentioned in our previous blog post.

    1. Create new report blank report with table 18


    2. Create DataItem ”Customer”

    3. Go to Section Designer and add the following fields:

    • No.
    • Name
    • Debit Amount

    4. Save the report as ID 50000 – Transfooter / Transheader

    5. Now go to Visual Studio (View / Layout)

    6. Create table and add the fields No, Name and Debit Amount

    7. Give this table the name "MainTable"

    8. Now we have added the basic for this report. But I would also like to have a Grand total of the Debit Amount so I add this as well. I add this in the Footer of the table

    ="GrandTotal: " & sum(Fields!Customer__Debit_Amount_.Value)


    9. Now if my report is printed I get a list of my all my customer with Debit Amount displayed and with GrandTotal in the end of the report:

    10. Now I create a small block of VBS code in order to perform some calculations and store intermediate data

    Open “Report->Report Properties” dialog and select “Code” tab, enter the following VBS code:

    11. Define a hashtable for storing running accumulated sums for each page of the report

    Shared RunningTotals As New System.Collections.Hashtable

    12. Define two public functions, which populate and query the hashtable from above

    Public Function GetRunningTotal(ByVal CurrentPageNumber)

    Return IIF(CurrentPageNumber > 0, RunningTotals(CurrentPageNumber), 0)

    End Function


    Public Function SetRunningTotal(ByVal CurrentPageTotal, ByVal CurrentPageNumber)

    RunningTotals(CurrentPageNumber) = CurrentPageTotal + GetRunningTotal(CurrentPageNumber - 1)

    Return RunningTotals(CurrentPageNumber)

    End Function 


    13. Ok, it’s now time to add a Transfooter and Transheader.

    Enable Page Header and Page Footer in the report (click “Report->Page Header” and “Report->Page Footer”).

    14. In the Page Footer I place a text box with the following expression:

    ="Transfooter subtotal = " & Code.SetRunningTotal( Sum(ReportItems!Customer__Debit_Amount_.Value), Globals!PageNumber)


    This code actually performs the following actions:

    - calculate the sum of all “Debit Amount” values on the current page (sic)

    - adds this value to the running total, which has been already calculated for the previous page

    - returns this value as the actual running total for the current page

    15. In the Page header I place a text box with the following expression:

    ="Transheader subtotal = " & Code.GetRunningTotal(Globals!PageNumber-1)

    This code fetches the running total, calculated up to the previous page


    16. And then I set distinctive BackgroundColor and font Color just so this Transfooter and Transheader stand out in my report


    17. Now I’m almost done but I would like to not see the Transheader on the first page and not to see the Transfooter on the last page.

    So I set the following expressions for the “Visibilty->Hidden” properties of the page header:

    =IIF(Globals!PageNumber > 1, False, True)

    And for the page footer:

    =IIF(Globals!PageNumber < Globals!TotalPages, False, True)

    18. Now I’m done, I save, import into NAV and compile. After some fit and finish on the report it now looks like this when I print

    Now I’m done, I save, import into NAV and compile. After some fit and finish on the report it now looks like this when I print:



    Question: Would this also work in the example of having a list of sales order lines per sales header and the sales order lines goes to multiple pages?

    Answer: The report above is a bit simplified in order to illustrate the point. It can be easily extended to support your scenario. I.e. the key for the hash should include page number AND header no to accomplish this.

    You can download the report object here, thanks to Nickolay Belofastow.

    /Claus Lundstrøm

  • Microsoft Dynamics NAV Team Blog

    It IS possible to instantiate the Visual Studio bridge.


    Solution developers will often have different versions of Dynamics NAV installed on a single machine for their development environment. The way this is often implemented is to fully install the latest version and simply copy the Classic Client binary files for earlier versions into separate folders so you have something like this:

    NAV 2009 R2 fully installed with an R2 SQL Server database
    C:\NAVCLIENTS\NAV 40 SP3\ClassicClient (containing NAV binary files. A NAV 4.0 SP3 database is also accessible on the machine)
    C:\NAVCLIENTS\NAV 50 SP1\ClassicClient (similar setup to above)
    C:\NAVCLIENTS\NAV 2009\ClassicClient
    C:\NAVCLIENTS\NAV 2009 SP1\ClassicClient

    This approach has been working for solution developers for some time now. However, after installing Dynamics NAV 2009 R2, if you then try to view the Layout for an NAV 2009 SP1 Report you will get the following error:

    Microsoft Dynamics NAV Classic
    It is not possible to instantiate  the Visual Studio bridge.

    This is due to a design change in NAV 2009 R2 which uses the .NetBridge rather than the old Visual Studio bridge component. However, the Visual Studio bridge files are included with the binaries in the NAV 2009 SP1 Classic Client folder so you can avoid the above error by running REGASM.EXE to register the DLL. The REGASM.EXE is included in the .Net Framework folder so executing the following command from within the NAV 2009 SP1 Classic Client folder should do the trick:

    C:\Windows\Microsoft.NET\Framework\v2.0.50727\regasm.exe Microsoft.Dynamics.Nav.VisualStudioBridge.DLL

    Of course, the REGASM.EXE may be located in a different path in your machine so alter the above command line as required.

    Gerard Conroy
    Microsoft Dynamics NAV Support

  • Microsoft Dynamics NAV Team Blog

    Running classic reports in RTC (RUNMODAL and a few other things)


    Just a few points about running classic reports from RTC, based on common support scenarios:

    RUNMODAL (Not possible)

    RTC runs classic reports (reports with no RDL Layout) by starting the report engine from a classic client. However, RTC is not able to run classic reports MODALLY. RUNMODAL as opposed to just RUN means that execution of the  next line of C/AL code waits until the report has completed. Of course RTC reports which DO have a layout can run MODALLY without any problems.

    So Report.RUNMODAL on a classic report from RTC does exactly the same as Report.RUN, i.e. RTC will launch the classic report engine but not wait for the report to finish before executing the next line of code. In most cases this doesn't matter. But the challenge is when the next line of code dependeds on the report having completed, for example to email the report, convert it to pdf, write back a result of the report to the database, or something else.


    Running batches of classic reports (Improvement)

    The good news is that there has been a few small other improvements relating to running classic reports from RTC. When the classic client closes, it updates a few files like the .zup file, and in the case of breakpoints having been used, also NaviBP.xml as described here:
    In case we launched a batch of classic reports, one instance of the classic report engine would start up for each report. And each instance could overwrite each other's files, leading to error messages like this:

    You cannot use the file C:\Users\[USER]\AppData\Roaming\fin.zup  because it is already in use.


    Microsoft Visual C++ Runtime Library
    Runtime Error!

    Program: C:...

     This application has requested the Runtime to terminate it in an unusual way.
    Please contact the application's support team for more information. 

    But with KB 2398170 (build 31587) the behaviour is changed, so that now when the classic client closes the report engine, it willl 1) only try to update the .zup file, and 2) not try to update naviBP.xml at all, avoiding the error messages mentioned above.

    Licenses (No, it doesn't consume a license)

    When you run a classic report from RTC, this does NOT consume a user license. If you watch the Session table while a classic report is running, you will see that a new session has connected, but with "Application Name" = '111'. In this way the system knows not to count it as a normal NAV client, so it will not count as a concurrent session.



    Lars Lohndorf-Larsen

    Microsoft Dynamics UK

    Microsoft Customer Service and Support (CSS) EMEA

  • Microsoft Dynamics NAV Team Blog

    MagicPath (DOWNLOADFROMSTREAM and UPLOADINTOSTREAM without a dialog box)


    The C/AL commands DOWNLOADFROMSTREAM and UPLOADINTOSTREAM have the purpose of sending files between RTC and the NAV Server. A few times now, we had the question: How can we use these functions without it displaying the dialog box to select a file and folder name?

    This is how you can automatically download and upload files without any user interactions:

    The trick is to use MagicPath, like in codeunit 419 "3-Tier Automation Mgt.". MagicPath is initiated by setting the folder name to '<TEMP>' like this:
    DOWNLOADFROMSTREAM(IStream,'','<TEMP>', '',MagicPath);



    The code example below will copy a specific file from the NAV Server to the RTC machine with no questions asked about folder or file name or anything else:

    FileToDownload := 'c:\Temp\ServerFile.txt';
    DOWNLOADFROMSTREAM(IStream,'','<TEMP>', '',MagicPath);
    MESSAGE('Path = ' + MagicPath);




    Name Data Type Length
    FileToDownload  Text 180
    FileVar File
    IStream  InStream
    MagicPath  Text 180


    Now we have the file on the RTC machine, and MagicPath tells us its location. The location will be something like this:
    C:\Users\[UserName]\AppData\Local\Temp\Microsoft Dynamics NAV\4612\__TEMP__ff7c5a286cfd463f9f7d92ae5b4757e2

    The number 4612 in the MagicPath comes from the Process ID of RTC.


    Handling files client side

    So, what if we wanted to rename it to a specific name? We have the FILE object in C/AL, but of course since C/AL runs on the NAV Server and not on RTC, this won't work since the purpose of the above is exactly to copy the file to the client machine. Instead, use this automation:

    'Microsoft Scripting Runtime'.FileSystemObject

    Then create an instance ClientSide:

    So, if you wanted to continue the code above and place and name the file to something specific on the client's machine, add these lines:

    DestinationFileName := 'c:\Temp\newfile.txt';
    IF FileSystemObject.FileExists(DestinationFileName) THEN



    MagicPath works both ways. But with DOWNLOADFROMSTREAM it creates MagicPath for you and tells you where it is. With UPLOADINTOSTREAM you need to know it in advance. Remember the MagicPath location above includes the Process ID of RTC. One way could be to work that out somehow. But what I would suggest instead, is to download a temp test file first, then see where MagicPath downloads it to. The path for upload will be the same:

    // download a temp file to get MagicPath
    DOWNLOADFROMSTREAM(IStream,'','<TEMP>', '',MagicPath);

    Then extract the folder name from MagicPath:

    FOR i := STRLEN(MagicPath) DOWNTO 1 DO BEGIN
      IF MagicPath[i] = '\' THEN BEGIN
        MagicPath := COPYSTR(MagicPath,1,i);
        i := 1;

    Once you know the location of MagicPath, the next step is to copy the file you want to upload into that folder:

    FileToUpload := 'newfile.txt';
    FolderName := 'c:\Temp\';

    IF ISCLEAR(FileSystemObject) THEN
    FileSystemObject.CopyFile(FolderName + '\' + FileToUpload,MagicPath + '\' + FileToUpload);

    Then use UPLOADINTOSTREAM to upload the file from MagicPath to the NAV Server:

    And finally, save the InStream to a file on the server:



    So, put all this together and the end result is:

    The file c:\Temp\ServerFile.txt gets downloaded to C:\Temp\NewFile.txt, and then uploaded back to the server as C:\Temp\OnServer.txt.



    Lars Lohndorf-Larsen

    Dynamics NAV Support EMEA






  • Microsoft Dynamics NAV Team Blog

    How to create/read xml file from Microsoft Dynamics NAV without using xmlports


    Periodically we receive support requests about XMLport errors, which really are missing features in xmlport's functionality.
    However most of these requests are rejected because: xmlports are not supposed to fulfill all possible xml standard scenarios.
    So there always will be xml file which can't be created or readed by NAV xmlport.
    Possible workaround could be to use XML DOM automations.

    Create it by codeunit:


     OBJECT Codeunit 50052 xml create
        Time=[ 1:33:31 PM];
        Version List=;
                xmlProcessingInst:=xmlDoc.createProcessingInstruction('xml','version="1.0" encoding="UTF-8" standalone="yes"');

                CurrNode := xmlDoc.appendChild(xmlProcessingInst);
                CurrNode := xmlDoc.createElement('soapenv:Envelope');
                CurrNode := xmlDoc.appendChild(CurrNode);


                  CurrNode:=NewChild; //One level deeper
                       CurrNode:=NewChild; //one level deeper
                            CurrNode:=NewChild; //one level deeper

                         recCustomer.SETRANGE("No.", '10000','20000'); //Filter only few records
                         IF recCustomer.FINDFIRST THEN BEGIN
                            vName   :=recCustomer.Name;
                            vNo     :=recCustomer."No.";
                              recCustomer.CALCFIELDS("Balance (LCY)");
                              vBalance:= FORMAT(recCustomer."Balance (LCY)");
                            vSPcode :=recCustomer."Salesperson Code";

                                  CurrNode1:=NewChild; //One level deeper, but keep current level too
                                         CurrNode2:=NewChild; //One level deeper to sublevel

                                         CurrNode2:=NewChild; //One level deeper to sublevel
                                             CurrNode1:=NewChild;//One level deeper

                            CLEAR(vNo)  ;

                           UNTIL recCustomer.NEXT=0;

                           MESSAGE('xmlFile.xml is created');

          xmlDoc@1000 : Automation "{F5078F18-C551-11D3-89B9-0000F81FE221} 6.0:{F6D90F11-9C73-11D3-B32E-00C04F990BB4}:'Microsoft XML, v6.0'.DOMDocument";
          CurrNode@1003 : Automation "{F5078F18-C551-11D3-89B9-0000F81FE221} 6.0:{2933BF80-7B36-11D2-B20E-00C04F983E60}:'Microsoft XML, v6.0'.IXMLDOMNode";
          CurrNode1@1005 : Automation "{F5078F18-C551-11D3-89B9-0000F81FE221} 6.0:{2933BF80-7B36-11D2-B20E-00C04F983E60}:'Microsoft XML, v6.0'.IXMLDOMNode";
          CurrNode2@1013 : Automation "{F5078F18-C551-11D3-89B9-0000F81FE221} 6.0:{2933BF80-7B36-11D2-B20E-00C04F983E60}:'Microsoft XML, v6.0'.IXMLDOMNode";
          NewChild@1004 : Automation "{F5078F18-C551-11D3-89B9-0000F81FE221} 6.0:{2933BF80-7B36-11D2-B20E-00C04F983E60}:'Microsoft XML, v6.0'.IXMLDOMNode";
          xmlProcessingInst@1001 : Automation "{F5078F18-C551-11D3-89B9-0000F81FE221} 6.0:{2933BF89-7B36-11D2-B20E-00C04F983E60}:'Microsoft XML, v6.0'.IXMLDOMProcessingInstruction";
          xmlMgt@1002 : Codeunit 6224;
          "---- Variables----"@1006 : Integer;
          recCustomer@1012 : Record 18;
          vName@1007 : Text[30];
          vNo@1008 : Text[30];
          vContact@1009 : Text[30];
          vBalance@1010 : Text[30];
          vSPcode@1011 : Text[30];

        EVENT xmlDoc@1000::ondataavailable@198();

        EVENT xmlDoc@1000::onreadystatechange@-609();



    And can be read by codeunit: 

    OBJECT Codeunit 50050 xml read
        Time=12:25:26 PM;
        Version List=;
                ffile.OPEN('D:\XmlFile.xml'); //this must be your file name

                IF ISCLEAR(xmldomDoc) THEN CREATE(xmldomDoc);


                xmlNodeList1 := xmldomDoc.getElementsByTagName('mbs:Customer');


                FOR i:=0 TO xmlNodeList1.length()-1 DO BEGIN
                 xmldomElem1:= xmlNodeList1.item(i); //mbs:Customer
                 IF xmldomElem1.hasChildNodes() THEN
                      xmlNodeList2:= xmldomElem1.childNodes();
                      IF NOT ISCLEAR(xmlNodeList2) THEN
                      xmldomElem2:= xmlNodeList2.item(0); //mbs:CustomerAuthentication
                      IF NOT ISCLEAR(xmldomElem2) THEN
                      IF xmldomElem2.hasChildNodes() THEN
                         xmlNodeList3:= xmldomElem2.childNodes();
                         IF NOT ISCLEAR(xmlNodeList3) THEN
                          xmldomElem3:= xmldomElem2.firstChild();//mbs:No
                         IF NOT ISCLEAR(xmldomElem3) THEN
                         xmldomElem3:=xmlNodeList3.item(1); //mbsName
                         IF NOT ISCLEAR(xmldomElem3) THEN

                      xmldomElem2:= xmlNodeList2.item(1); //mbs:CustomerData
                      IF NOT ISCLEAR(xmldomElem2) THEN
                      IF xmldomElem2.hasChildNodes() THEN
                         xmlNodeList3:= xmldomElem2.childNodes();
                         IF NOT ISCLEAR(xmlNodeList3) THEN
                          xmldomElem3:= xmldomElem2.firstChild();//mbs:Balance
                         IF NOT ISCLEAR(xmldomElem3) THEN
                         xmldomElem3:=xmlNodeList3.item(1); //mbsSalesPersonCode
                         IF NOT ISCLEAR(xmldomElem3) THEN

                         xmldomElem3:=xmlNodeList3.item(2); //mbs:Contacts
                         IF NOT ISCLEAR(xmldomElem3) THEN

                      MESSAGE('This is record "%1"\No "%2"\Name "%3"\Contact "%4"\Balance "%5"\Salesperson code "%6"\of Total "%7"',


          xmldomDoc@1000 : Automation "{F5078F18-C551-11D3-89B9-0000F81FE221} 6.0:{F6D90F11-9C73-11D3-B32E-00C04F990BB4}:'Microsoft XML, v6.0'.DOMDocument";
          xmlNodeList1@1005 : Automation "{F5078F18-C551-11D3-89B9-0000F81FE221} 6.0:{2933BF82-7B36-11D2-B20E-00C04F983E60}:'Microsoft XML, v6.0'.IXMLDOMNodeList";
          xmlNodeList2@1017 : Automation "{F5078F18-C551-11D3-89B9-0000F81FE221} 6.0:{2933BF82-7B36-11D2-B20E-00C04F983E60}:'Microsoft XML, v6.0'.IXMLDOMNodeList";
          xmlNodeList3@1019 : Automation "{F5078F18-C551-11D3-89B9-0000F81FE221} 6.0:{2933BF82-7B36-11D2-B20E-00C04F983E60}:'Microsoft XML, v6.0'.IXMLDOMNodeList";
          xmldomElem1@1007 : Automation "{F5078F18-C551-11D3-89B9-0000F81FE221} 6.0:{2933BF86-7B36-11D2-B20E-00C04F983E60}:'Microsoft XML, v6.0'.IXMLDOMElement";
          xmldomElem2@1010 : Automation "{F5078F18-C551-11D3-89B9-0000F81FE221} 6.0:{2933BF86-7B36-11D2-B20E-00C04F983E60}:'Microsoft XML, v6.0'.IXMLDOMElement";
          xmldomElem3@1011 : Automation "{F5078F18-C551-11D3-89B9-0000F81FE221} 6.0:{2933BF86-7B36-11D2-B20E-00C04F983E60}:'Microsoft XML, v6.0'.IXMLDOMElement";
          txtNo@1001 : Text[30];
          txtName@1002 : Text[30];
          txtContact@1009 : Text[30];
          txtBalance@1012 : Text[30];
          txtSPcode@1013 : Text[30];
          ffile@1003 : File;
          strInStream@1004 : InStream;
          i@1006 : Integer;
          ii@1018 : Integer;

        EVENT xmldomDoc@1000::ondataavailable@198();

        EVENT xmldomDoc@1000::onreadystatechange@-609();


    That's all
    Special thanks to
    Rainer Kuhnlein

    Gedas Busniauskas (gediminb)
    Microsoft Customer Service and Support (CSS) EMEA


  • Microsoft Dynamics NAV Team Blog

    More Charts


    This is a follow up to this post:

    Using Client Extensibility in NAV 2009 SP1 to create Charts

    News in this post are:

    2-series line charts. For example showing number of new Orders and Quotes for the last 10 days:


    Item Sales Chart (basically identical to the Customer Sales Chart in the previous post):


    Doughnut charts have been shined up a bit to make them look better:


    Double-click callback to NAV: When you double-click a chart, it will call the ControlAddin trigger. The example below will open up a list of Cust. Ledger Entries when double-clicking on a chart on the Customer Card page:

    Sales (LCY) - OnControlAddIn(Index : Integer;Data : Text[1024])
    CustLedgEntry.SETCURRENTKEY("Customer No.");
    CustLedgEntry.SETRANGE("Customer No.","No.");

    All you need is attached at the end of this post. It contains .dlls, including their source code, and a NAV codeunit. To implement some examples:

    Implement the charts add-on:

    1)  If you want to modify the attached c# project you must install "Microsoft Chart Controls Add-on for Microsoft Visual Studio 2008".

    2)  On any client machine where you want to run the charts, you must install "Microsoft Chart Controls for Microsoft .NET Framework 3.5".

    3)  Detach and unzip the attached file.

    4)  From the unzipped file, copy the files from \XTCharts\bin\Debug\ into the "Add-ins" sub folder of the RoleTailored Client (RTC).

    5)  And import the codeunit from XTChart.fob in Object Designer.

    6)  In a Classic Client, run table 2000000069 "Client Add-in" and enter one line (if it doesn't already exists from the previous post):

    Control Add-in Name:    XTChart
    Public Key Token:    d1a25808afd603da

    (making sure to have exactly these values, in the right case)

    Adding charts to pages:

    On the page where you want a chart, insert a new line of type Field. In the property "ControlAddIn", select the XTChart (XTChart;PublicKeyToken=d1a25808afd603da). This adds the control itself. To send data to the control you must specify SourceExpression too. Declare a Global variable called XTChartUtil, Type = Codeunit, Sub Type = Codeunit 75550 "XT Chart Util" to use in SourceExpression. If the chart is on a Customer Card page, then specify this SourceExpression:

    For a line-chart, showing "Sales (LCY)" for the last 6 months:  XTChartUtil.CustPointsChart(Rec)

    For a Doughnut chart, showing "Balance (LCY)" percentage of "Credit Limit": XTChartUtil.CustDoughnutChart(Rec)

    On an Item Card page, for a line chart showing Item "Sales (LCY)" for the last 6 months, have SourceExpressions XTChartUtil.ItemPointsChart(Rec)

    On the main Role Centre, to have a 2-series chart showing number of Quotes and Orders created in the past 10 days, I added the chart in Page 9060 with this SourceExpression: ChartUtil.SalesCueChart

    Then, for each example above, if you want to trigger any activity when the user double clicks the chart, just put some C/AL code on the corresponding OnControlAddIn-trigger.

    You can add charts in many other places, except for pages of the following types which cannot handle Extensibility components:

    • Under a Repeater Control (i.e. a list page)
    • Action Pane
    • Command Bar
    • Filter Pane


    In the example here, I added a chart to the main Role Centre. In a production environment this is maybe not such a good idea, for these two reasons:

    1)  If a chart goes wrong and crashes, for example if a user has not installed the Chart Controls for .NET (link above), then it may crash the whole RTC. If this happens from some page which shows a chart, then at least the user knows that such and such page has a problem. If it happens on the Role Centre, then RTC will crash as soon as it is opened, and the user cannot use RTC at all, and it may not be obvious why RTC crashes.

    2)  Performance is not great in the SalesCueChart-example here, counting Sales Header records filtering on "Document Date". If a company has 1.000s of orders, then this would have some impact on performance. So, at least only calculate the chart on request, and not on the main page whether the user actually needs it or not.

    Development notes

    If you want to extend this to create new charts, then this is how the attached example works:

    Chart Data is generated in xml format in codeunit 75550 "XT Chart Util". It has a function for each type of chart. The xml data must have this format:

    - <Chart>

    <ChartType>1</ChartType> <-- Chart Type 1 = Lines, 2 = Doughnut and 3 = 3D lines

    - <Data Title="Orders"> <-- Title is optional. If specified, it will show as legend on the chart

    <REC1 Title="16/01/11">0</REC1> <-- Name the elements REC1, REC2, etc.

    <REC2 Title="17/01/11">2</REC2>

    <REC3 Title="18/01/11">0</REC3>

    <REC4 Title="19/01/11">2</REC4>


    - <Data2 Title="Quotes"> <-- Data2 section is optional. Used for making 2-series charts. If there is a Data2 section, then it must have the same number of elements as Data, and with the same names.

    <REC1 Title="16/01/11">0</REC1>

    <REC2 Title="17/01/11">0</REC2>

    <REC3 Title="18/01/11">0</REC3>

    <REC4 Title="19/01/11">1</REC4>



    In case of a Doughnut chart, just generate an xml document like this:

    - <Chart>


    - <Data>

    <REC1 Title="Balance">9.20</REC1>

    <REC2 Title="CreditLimit">90.80</REC2>



    with 2 REC-elements which total up to 100.

    The c#-code is all inside of one big try{} catch{} - structure. If anything goes wrong, then it will just show the data that was received in a MessageBox, but not what actually went wrong. Only if you remark the try{} and catch{} - section, it will throw the actual error message to tell you what went wrong (it should log it in the Application log). But the downside of this is, that RTC is also likely to crash.

    Lars Lohndorf-Larsen


    This posting is provided "AS IS" with no warranties, and confers no rights

  • Microsoft Dynamics NAV Team Blog

    How to get a Dynamics NAV report with a Web Service


    1. Create a new codeunit. In this scenario we will call this codeunit "CUWebReport" with ID 50000

    2. Navigate to "C/AL Globals" and create a function called "GenerateReport"


    3. Select "Locals"

    4. Select the "Return Value" tab

    5. Set "Return Type"=Text and "Length"=100


    6. With this completed close "C/AL Locals" window.

    7. Now with "C/AL Globals" windows active again. Select "Variables" tab.

    8. Create a variable called "filename" with "Data Type"=Text and "Length"=100


    9. Now let's add the following code to this codeunit:

    filename := 'C:\inetpub\PdfDocuments\';
    filename += FORMAT(CREATEGUID);
    filename := DELCHR(filename, '=', '{-}');
    filename += '.pdf';


    10. Save and compile the codeunit.

    11. Now it's time to expose this codeunit as Web Service. Navigate to "Administration/IT Administration/General Setup/Web Services"

    12. Select codeunit 50000 and give this a service name, we use "Get_PDF_Report"


    13. Now it is time to verify that we can see this web service. Open this URL  http://localhost:7047/DynamicsNAV/WS/services.

    You should now see this message in your browser, and your Web Service can now be called :


    If you don't see this message, you might want to check that  the service "Microsoft Dynamics NAV Business Web Services" has been started.

    14. Now it is time to call the Web Service, in this example we use Microsoft Visual Web Developer 2005. And we use the following code to call the Web Service:

    Partial Class _Default
        Inherits System.Web.UI.Page

        Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
            Dim service As localhost.Get_PDF_Report = New localhost.Get_PDF_Report()
            service.UseDefaultCredentials = True
            service.Url = "
            Response.ContentType = "application/pdf"
            Dim pdfFileName As String = service.GenerateReport()

        End Sub
    End Class

    But how to consume this Web Service is not in scope for this blog, so we suggest you have look our online help how to consume a Web Service from NAV 2009.

    Online help found here:

    15. Now also remember to impersonate your web servers application to an appropriate Dynamics NAV user.

    16. After compiling a running our project we then get this button in our browser.


    17. When activating this button, we get the report specified in Codeunit 50000 displayed as an PDF file in our browser.


    Conclusion, now you can give this URL to people who don't have access to Dynamics NAV, and they can execute the report when they see a need for this.


    Torben Meyhoff, SDE & Claus Lundstrøm, Program Manager, Microsoft Dynamics NAV

  • Microsoft Dynamics NAV Team Blog

    Microsoft Dynamics NAV and SQL Server Database Compression


    Microsoft SQL Server 2008 introduces two new compression features (available in Enterprise Edition) that are of interest to users with large databases. Data compression applies to individual tables and indexes within a database and comes in two options: ROW and PAGE. Backup compression is a new option when backing up a database to external storage. Both compression techniques can be used to reduce the amount of online storage required for databases. Data compression can be configured for an entire heap (table with no clustered index), clustered index, non-clustered index, or indexed view. For partitioned tables and indexes, the compression option can be configured separately (and differently) for each partition. Compression can also reduce disk utilization and sql memory utilization as dead is stores on disk in a compressed state and also reads in the SQL cache in a compressed state. Compression can add 10 - 30% percent increased CPU utilization depending on what tables and indexes are compressed and what level of compression is used.

    For Dynamics NAV we recommend only compressing tables and indexes that have a read to write ration of 80%/20% (This is a conservative threshold) or higher as compressing tables with a higher write ratio can actually decrease performance. We also recommend using ROW compression if the space saving between ROW and PAGE level compression is less that 10%; if the difference is over 10% then we recommend PAGE compression. This is because if the space savings from PAGE compression is close to or similar to ROW compression then it is not recommended to incur the additional overhead associated with PAGE compression. An example of NAV tables that would benefit greatly from compression are the large "Entry" tables such as G/L Entry, Value Entry, and Item Ledger Entry. An example for NAV tables that would not benefit from compression and where performance may actually decrease due to compression are "Line" tables where the data is temporary in nature such as Sales Line, Purchase Line, and Warehouse Activity Line. SQL Server compression is completely transparent to the Dynamics NAV application.

    Compression is done on Table or Index basis. On tables with clustered indexes the clustered index is the table so compressing the clustered index is equal to compressing the table. Running the ALTER TABLE.. WITH COMPRESSION is only necessary on HEAPS for all tables with Clustered Indexes you can use the ALTER INDEX.. WITH COMPRESSION.

    How to determine the read/write ratio of an index? Luckily SQL keeps track of this for us and all we need to do is extract this data. SQL Server stores this information in the sys.dm_db_index_operational_stats DMV. Remember DMV's are "recycled" each time the SQL Server service is restarted so if SQL has only been up and running for a day or a week this information will be of minimal use. Ideally you would want the server to be up any running for several weeks and through a month end close to get a true idea of actual data access patterns of your database.

    The following query will tell you how long the SQL Server instance has been up and running:

    select 'Sql Server Service has been running for about '

           + cast((datediff(hh, create_date, getdate()))/24 as varchar(3)) + ' days and '

           + cast((datediff(hh, create_date, getdate())) % 24 as varchar(2)) + ' hours'

           from sys.databases where name = 'tempdb'

    The following query will give the approximate read write balance of all the used indexes in the database.







                            i.leaf_update_count * 100.0 /

                                  (i.range_scan_count + i.leaf_insert_count

                                      + i.leaf_delete_count + i.leaf_update_count

                                      + i.leaf_page_merge_count + i.singleton_lookup_count

                                  ) as Writes,

                            i.range_scan_count * 100.0 /

                                  (i.range_scan_count + i.leaf_insert_count

                                      + i.leaf_delete_count + i.leaf_update_count

                                      + i.leaf_page_merge_count + i.singleton_lookup_count

                                  ) as Reads

                  FROM sys.dm_db_index_operational_stats (db_id(), NULL, NULL, NULL) i

                  JOIN sys.sysobjects o ON = i.object_id

                  JOIN sys.indexes x ON x.object_id = i.object_id AND x.index_id =


                  JOIN sys.sysindexes s ON = x.object_id and s.indid = x.index_id

                  WHERE (i.range_scan_count + i.leaf_insert_count

                            + i.leaf_delete_count + leaf_update_count

                            + i.leaf_page_merge_count + i.singleton_lookup_count) <> 0

                  AND objectproperty(i.object_id,'IsUserTable') = 1


    You can also run a simulation with the sp_estimate_data_compression_savings stored procedure in SQL with will run a sample of the data through the chose compression level and give you the estimate of the space saved by enabling compression.

    I strongly recommend reading the following MSDN article before engaging in database compression activities.

    Note: You can use the following query to check to see if there are currently any compressed indexes in the database.

    SELECT Table_Name, p.index_id as Index_ID, as Index_Name,


          WHEN p.data_compression = 1 THEN 'ROW Compression'

          WHEN p.data_compression = 2 THEN 'PAGE Compression'

          ELSE 'ERROR'

          END Compression_Type

    FROM sys.partitions p

    JOIN sys.objects o ON p.object_id = o.object_id

    JOIN sys.sysindexes i ON o.object_id = AND p.index_id = i.indid

    AND p.data_compression in (1,2)

    ORDER BY, p.data_compression, p.index_id


    Michael De Voe

    Senior Premier Field Engineer

    Microsoft Dynamics

    Microsoft Certified Master - SQL Server 2008

  • Microsoft Dynamics NAV Team Blog

    About Object Metadata, and why I can't see object changes in RTC



    A few times we have seen case where changes to NAV objects are not seen in RTC until the NAV Server is restarted. This post explains a likely solution to such problems. And as we are on the topic anyway, also explains a bit about the process that turns C/AL code into Metadata (c#).


    How object changes get to RTC

    When you save an object in Object Designer, then table 2000000071 "Object Metadata" is updated as well. An easy way to see this part of the process in action is:
    Run table 2000000071 and delete Page 1 (or any object). Then compile Page 1 from Object Designer. Then check that it has been re-created in table 2000000071.

    If you look at this table in SQL Server Management Studio, you can see that it has SQL triggers which update the table "Object Tracking". It is the "Object Tracking" table that NAV Server uses to see when an object has changed, so that it knows to send updated Metadata to RTC.

    There are two ways that the NAV Server can get updated on activity in the "Object Tracking" table:
      SQL Server Broker


    SQL Broker

    If SQL Server Broker is enabled, then NAV Server will rely on that to notify it when an object has changed. You can see whether the broker is enabled from SQL Server Management Studio under Database Properties, then under Options look for "Broker Enabled".

    If the broker is enabled, then when NAV Server starts up and on first activity (When first RTC connects), it will create a queue and a service under SQL Service broker. You can see this in SQL Server Management Studio under the NAV Database if you expand Service Broker. Here, under Queues and under Services you will see new objects with names like SqlQueryNotificationService-27b7fb21-74a7-4a63-876a-c96b8eecd583. These are created by NAV Server and removed again when NAV Server stops. Their job is to listen to the "Object Tracking" table and notify NAV Server when there are any changes there.



    If the broker is not enabled, then NAV Server will use polling, i.e. check for changes every now and then. You can see this in two ways. First in the Application Log the NAV Server will log this event shortly after startup:

    Service: MicrosoftDynamicsNavServer
    SQL Query Notifications are unavailable on SQL Server '.' in Database 'NAVDatabase'. The Object Change Listener has switched to polling.

    Secondly, when NAV Server is in polling mode and you start SQL Profiler you will see this query being run regularly by .New sqlClient Data Provider:

    exec sp_execute 1,@lastKnownTimeStamp=463223

    This is a pre-prepared query which looks like this:

    SELECT [Object Timestamp], [Object Type], [Object ID], [Object Key] FROM [dbo].[Object Tracking] WHERE [Object Timestamp] > @lastKnownTimeStamp',@lastKnownTimeStamp=463225

    In polling mode, this is how NAV Server checks for object changes since last time it checked, so it knows whether to send updated object definitions (metadata) to RTC.



    So that's the background. How do we handle the case where object changes are not seen in RTC until we restart NAV Server? If this problem happens, then switch method from SQL Broker to Polling or visa versa. You switch by enabling / disabling the broker like this:


    The "WITH ROLLBACK IMMEDIATE"-part of this query is to avoid what happened for me that the query just hang, or would only run if the database was put in single user mode.

    In the cases we have seen, the broker has been enabled but had some kind of problem. A slightly cryptic message was recorded in the SQL Server Log every time an object was changed in Object Designer. This message was not logged in the Application log. So make sure to check in SQL Server Management Studio under Management -> SQL Server Logs -> Current. If this gives enough information to solve the problem then good. If not, then there is the option of switching to polling (disable the broker) until the root of the problem can be resolved.

    Enabling the broker is the preferred option since it saves NAV Server for checking ever so often for object changes. But if the broker doesn't work then at least there is the option to disable it until any problems can be resolved.


    Lars Lohndorf-Larsen

    Dynamics NAV Support EMEA


  • Microsoft Dynamics NAV Team Blog

    Microsoft Dynamics NAV 2013 R2 available in the Windows Azure Portal under MSDN subscription


    Ever wondered what it is like to work with Microsoft Dynamics NAV on Windows Azure - but found it too cumbersome even with our nice Windows Azure provisioning tools?  Then this might be something for you. 

    Today we have made Microsoft Dynamics NAV 2013 R2 easily available on Windows Azure with just a few clicks. The Microsoft Dynamics NAV 2013 R2 image is an exclusive offer for MSDN subscribers and includes a fully functional, ready to use Microsoft Dynamics NAV 2013 R2 installation including Microsoft SQL Server. The MSDN subscription gives you the well-known discounted prices and allows you to use it for development, test, and demo purposes, but not for production purposes.

    How to get it? Make sure you have an MSDN subscription and the subscription has Windows Azure benefits activated. Then follow these steps:


    1. Sign in to the Windows Azure Portal using your MSDN subscription.
    2. Choose the + sign at the bottom of the Portal page.
    3. Choose Compute, point to Virtual Machine, and then choose From Gallery.
    4. Select the MSDN filtering checkbox as shown in the following screenshot. This will filter the list to only show the available MSDN images.

    1. Choose the Microsoft Dynamics NAV 2013 R2 image.
    2. Choose the arrow in the lower-right corner.
    3. Fill in the relevant fields about the virtual machine as described in the following list:
      1. Specify the name of the virtual machine.
      2. Specify the size of the virtual machine, such as Medium.
      3. Specify the user name and password for connecting to the virtual machine.
      4. Specify the region  where you want to host your virtual machine, such as West Europe.
      5. Verify the remaining parameters. In most cases, the default values are sufficient.
    4. Choose the Finish icon to start the provisioning process.
    5. Once the image is provisioned after a few minutes, you can use Remote Desktop to connect to it. In the Azure Portal Virtual Machine page, choose the newly created image, and then choose Connect. Use the credentials that you specified step 7.

    When you are connected to the VM, you are welcomed to the Microsoft Dynamics NAV 2013 R2 virtual machine on Windows Azure:

    No further configuration is required and you can immediately start using the clients and the development environment.

    Best regards

    Kamil Koclega & Morten Jensen from the Dynamics NAV team

  • Microsoft Dynamics NAV Team Blog

    Update Rollup 4 for Microsoft Dynamics NAV 2013 R2 has been released


    Update rollup 4 includes all application and platform hotfixes and regulatory features that have been released for Microsoft Dynamics NAV 2013 R2 and includes hotfixes that apply to all countries and hotfixes specific to the following local versions:

    • AU – Australia
    • DE - Germany
    • DK - Denmark
    • FR - France
    • IT - Italy
    • NA – North America
    • NL – Netherlands
    • NZ – New Zealand
    • SE - Sweden
    • UK - United Kingdom


    New in update rollup 4 

    Beginning with update rollup 4, the update rollups for Microsoft Dynamics NAV 2013 R2 now also includes hotfixes for the upgrade toolkit. 


    Where to find update rollup 4

    You can download update rollup 4 from KB 2930617 - Update Rollup 4 for Microsoft Dynamics NAV 2013 R2 (Build 36078).

    The hotfixes that have been released since update rollup 3 are listed in KB 2930617. For a full list of all hotfixes included in the update rollup, see the following CustomerSource and PartnerSource pages: 




    More Information

    For more information about update rollups for Microsoft Dynamics NAV 2013 R2, see Announcement of update rollups for Microsoft Dynamics NAV 2013 R2.

  • Microsoft Dynamics NAV Team Blog

    Memory usage in Microsoft Dynamics NAV 2013 print preview


    Periodically we receive requests where customers asking us about RTC print preview consumes all available memory and computers hangs.

    Repro scenarios are more/less similar: run report, click preview, go per pages up/down, close report. Run another report, click preview, go per pages up down and… RTC hangs.
    If we look to memory usage, NAV is using all available memory.

    If we analyze what has happened, we see: with every move per pages memory usage increase and increase and increase until all memory is used.
    It looks like typical memory leak because in NAV 2009 with the same repro everything is OK.

    However it is not so simple. What NAV does in this scenario is: it loads Microsoft Report Viewer 2010 with 2 files: report definition (RDL file where is described report structure) and record set. And that is all, next actions like preview/print/export are managed by report viewer. The same we have in NAV 2009 just it loads Report Viewer 2008 and .NET Framework 3.5 as NAV 2013 uses Report Viewer 2010 and .NET Framework 4.5. And here is reason pointing us to memory usage behavior: Report Viewer 2010 and .NET 4.5 uses another way to manage memory (named more advanced and more secure). However this ‘another’ way gets us mentioned questions from customers and really we can do nothing from NAV platform side – system works as it is designed to work.

    But things are not so bad. In .NET memory is managed very smart and not used memory is released by function named ‘garbage collector’. This function periodically review memory blocks and release not used. And actually it works: if we monitor memory during report previewing and after it close we see that in preview and going per pages memory usage increase, after preview close memory usage is still the same, but after 5-10 min used memory decrease to initial numbers. For example in my tests started RTC using 98.5 MB, after few previews and scrolls and etc. usage increases to 215 MB and doesn’t decrease if I close preview. But after few minutes garbage collector returns usage to 100.4 MB.
    We can force (in NAV platform) garbage collector to work faster and memory release will be faster, but this will increase processor usage and in many cases it is worse than memory usage.

    Few trick could help users do not meet memory problems:

    1. When we open report preview we see report in “funny” interactive mode. This is preview mode where we can change report view in some way described in report code. For example in report ‘Customer – Top 10 List’ sorting can be changed. But exactly this mode is memory monster. If we click ‘Print layout’ button in menu we come to ‘page view’ where we can change nothing in report and see exactly what will be printed. This mode doesn’t use memory so much, so we can use this view easier. Few additional points here: a) all report initially open in interactive mode so users need manually change mode; b) Mode is not available if report is not allowed to preview like Sales Invoice or Order Confirmation.
    2. Report run SAVEASPDF works better if we call it directly without request form. However then users need to do more actions to open report. But maybe this can be reasonable in some cases.
    3. And finally if there are requirements to run big reports with many pages (100 and more) then better is to run them on server side, just because server is 64 bits and usually has more available RAM. This can be done by creating codeunit which runs report SAVEASPDF. Then add codeunit to job queue. Job queue executes codeunit and create pdf file.


    New Information since Update Rollup 5:




    These postings are provided "AS IS" with no warranties and confer no rights. You assume all risk for your use.


    Gedas Busniauskas
    Microsoft Lithuania
    Microsoft Customer Service and Support (CSS) EMEA


  • Microsoft Dynamics NAV Team Blog

    Introducing the Microsoft Dynamics NAV Application Profiler


    Did you ever wish you could monitor how your application code performs at real time? We have produced a sample and a video that can help you get started with C/AL tracing and application performance profiling.

    Get the Microsoft Dynamics NAV Application Profiler here,, and watch the video on how to install, configure and use this tool to enable C/AL code tracing and determine application performance during code execution here,


    David Worthington and Dmytro Sitnik from the Dynamics NAV team

    Format: ???
    Duration: 7:00

  • Microsoft Dynamics NAV Team Blog

    Cumulative Update 7 for Microsoft Dynamics NAV 2013 R2 has been released


    Cumulative update 7 includes all application and platform hotfixes and regulatory features that have been released for Microsoft Dynamics NAV 2013 R2. 

    The cumulative update includes hotfixes that apply to all countries and hotfixes specific to the following local versions:

    • AU - Australia
    • AT - Austria
    • BE - Belgium
    • CH - Switzerland
    • DE - Germany
    • DK - Denmark
    • ES - Spain
    • FI  - Finland
    • FR - France
    • IS - Iceland
    • IT - Italy
    • NA - North America
    • NL - Netherlands
    • NO - Norway
    • NZ - New Zealand
    • RU – Russia
    • SE - Sweden
    • UK - United Kingdom

    Where to find cumulative update 7

    You can download cumulative update 7 from KB 2964528 – Cumulative Update 7 for Microsoft Dynamics NAV 2013 R2 (Build 36703 - our apologies for originally posting the wrong build number).

    For a full list of all hotfixes included in cumulative updates for Microsoft Dynamics NAV 2013 R2, see the following CustomerSource and PartnerSource pages: 



    More Information

    For more information about cumulative updates for Microsoft Dynamics NAV 2013 R2, see Announcement of update rollups for Microsoft Dynamics NAV 2013 R2

Page 4 of 48 (719 items) «23456»