Standard application interfaces

We discussed all the available interface technologies for Microsoft Dynamics NAV. Let's have a look at how this has been implemented in the standard product.

In this book, we will not explore each interface in depth since that would almost require another book. We will just briefly discuss where to find all technologies we discussed in the standard application and indicate where a white paper or website can be found.

An example of flat file is Exporting Contacts. Microsoft Dynamics NAV allows us to export our contacts using an XMLPort.

The XMLPort for this functionality has number (5050) and uses the Format Variable Text. Other options are Xml and Fixed Text, as shown in the following screenshot:

Standard application interfaces

XMLPorts have a node structure like pages. The XMLPort starts with integer table as the first data type followed by the Contact table fields.

Microsoft Dynamics NAV and Microsoft Office are integrated to use with Word, Excel, and Outlook. We will first discuss the standard Word and Excel integration and discuss alternatives later. Lastly, we will briefly discuss the possibilities for Outlook integration.

In Microsoft Dynamics NAV, each form or page can be exported to Word and Excel. This built-in technology is automatically provided by the user interface and requires no effort from developers.

To be more flexible in the layout, Microsoft has released a style sheet tool for Microsoft Dynamics NAV and Word. This tool allows users to easily generate style sheets.

Style sheet tool

The manual provided with the style sheet tool gives a good description about how to create the style sheets.

Style sheet tool

Add the action to the action designer (under the appropriate group) with the following properties:

Expanded    Type    SubType    Name                Caption
0           Action             <Action680>         Style Sheets

The OnAction trigger should contain the following line:

StyleSheetDataMgt.LoadStylesheetDataRTC(GETPOSITION,
  CURRENTKEY,PAGE::"<<PageName>>");

Here, StyleSheetDataMgt is a variable of type codeunit, 682 (Style Sheet Data Management).

When exporting information to Excel that needs to be combined from different parts of the application, using style sheets is not the ideal way.

To support this, the Excel Buffer table (370) can be used. This table can be populated with data and then sent to Excel using a simple C/AL command.

This is used in several parts of the application, for example, to import and export the budgets we discussed in Chapter 3, Financial Management.

Let's create a sample codeunit that exports data to Excel using the Excel Buffer table:

  1. Create a new codeunit and define a global variable of type record Excel buffer. This needs to be a temporary variable. Also, define the other variables as displayed in the following screenshot:
    Advanced Excel integration
  2. Create a new EnterCell function with the parameters displayed in the following screenshot:
    Advanced Excel integration
  3. Put the C/AL code in place that will handle the interface:
    OnRun()
    ExcelBufTemp.CreateBook(Cust.TABLECAPTION);
    
    Cust.FIND('-');
    REPEAT
      RowNo := RowNo + 1;
      EnterCell(RowNo, 1, Cust."No.", FALSE, FALSE, '');
    
      FormAddr.Customer(Addr, Cust);
      EnterCell(RowNo, 2, Addr[1], FALSE, FALSE, '');
      EnterCell(RowNo, 3, Addr[2], FALSE, FALSE, '');
      EnterCell(RowNo, 4, Addr[3], FALSE, FALSE, '');
      EnterCell(RowNo, 5, Addr[4], FALSE, FALSE, '');
      EnterCell(RowNo, 6, Addr[5], FALSE, FALSE, '');
      EnterCell(RowNo, 7, Addr[6], FALSE, FALSE, '');
      EnterCell(RowNo, 8, Addr[7], FALSE, FALSE, '');
      EnterCell(RowNo, 9, Addr[8], FALSE, FALSE, '');
    
    UNTIL Cust.NEXT = 0;
    
    ExcelBufTemp.WriteSheet(Cust.TABLECAPTION,COMPANYNAME,USERID);
    ExcelBufTemp.CloseBook;
    ExcelBufTemp.OpenExcel;
    ExcelBufTemp.GiveUserControl;
    EnterCell()
    ExcelBufTemp.INIT;
    ExcelBufTemp.VALIDATE("Row No.",RowNo);
    ExcelBufTemp.VALIDATE("Column No.",ColumnNo);
    ExcelBufTemp."Cell Value as Text" := CellValue;
    ExcelBufTemp.Formula := '';
    ExcelBufTemp.Bold := Bold;
    ExcelBufTemp.Underline := UnderLine;
    ExcelBufTemp.NumberFormat := NumberFormat;
    ExcelBufTemp.INSERT;

This C/AL code will browse the customers in the database and format the addresses using the Address Format (365) codeunit.

The Customer No. field and the result array Addr[] are saved in the Excel buffer table. Lastly, we start the C/AL functions to generate the Excel spreadsheet based on the data.

Microsoft Dynamics NAV 2013 allows different levels of interfacing with Microsoft Outlook:

Microsoft Dynamics NAV 2013 RTM was shipped with a special SharePoint client. However, since this was directly discontinued in R2 we will not discuss this.

In Microsoft Dynamics NAV 2013 R2, the web client is SharePoint-compliant. To use Microsoft Dynamics NAV 2013 R2 in combination with SharePoint, it is possible to add web parts that connect to the web client.

It is possible to connect to both the on premise version of SharePoint and SharePoint Online.

Microsoft Dynamics NAV 2013 ships with one client add-in for Microsoft Connect. An example page object that uses the Connect control is Connect (9175).

Client add-ins

Let's have a look at how this done.

Client add-ins

The page type of this page is CardPart and it has no source table. The only control on the page is Parameters, which is a function with a Text (350) return value.

The ControlAddIn property points to the add-in that will be used when this page is started. This add-in will replace the original control on the page.

In the Parameters function, a string is created to feed information into the connect add-in enabling it to show information that is interesting for the current role. This is done using a combination of other C/AL functions:

In Chapter 7, Storage and Logistics, Client Extensibility and Bing Maps are used to show the stops of a route on a map.

The available libraries are stored in the client add-in table (2000000069).