Book Image

Microsoft Dynamics NAV 2009 Programming Cookbook

By : Matthew Traxinger
Book Image

Microsoft Dynamics NAV 2009 Programming Cookbook

By: Matthew Traxinger

Overview of this book

Microsoft Dynamics NAV 2009 is a business management solution that helps simplify and streamline highly specialized business processes such as finance, manufacturing, customer relationship management, supply chains, analytics, and electronic commerce for small and medium-sized enterprises. ERP systems like NAV thus become the center of a company's day-to-day operations. When you learn to program in an environment like this it opens up doors to many other exciting areas like .NET programming, SQL Server, and Web Services.Microsoft Dynamics NAV 2009 Programming Cookbook will take you through interesting topics that span a wide range of areas such as integrating the NAV system with other software applications like Microsoft Office, creating reports to present information from multiple areas of the system, and so on. You will not only learn the basics of NAV programming, but you will also be exposed to the technologies that surround the NAV system such as .NET programming, SQL Server, and Web Services.The first half of the cookbook will help programmers coming to NAV for the first time by walking them through the building blocks of writing code and creating objects like tables, forms, and reports. The second half focuses on using the technologies surrounding NAV to build better solutions. You will learn how to write .NET code that works with the NAV system and how to integrate the system with other software applications like Microsoft Office or even custom programs. You will also discover some of the features of the Role Tailored Client including creating Pages and custom add-ins.
Table of Contents (18 chapters)
Microsoft Dynamics NAV 2009 Programming Cookbook
Credits
About the author
About the reviewer
Preface
Index

Preface

Microsoft Dynamics NAV 2009 is a business management solution that helps simplify and streamline highly specialized business processes such as finance, manufacturing, customer relationship management, supply chains, analytics, and electronic commerce for small and medium-sized enterprises. ERP systems like NAV thus become the center of a company's day-to-day operations. When you learn to program in an environment like this, it opens up doors to many other exciting areas such as .NET programming, SQL Server, and Web Services.

Microsoft Dynamics NAV 2009 Programming Cookbook will take you through interesting topics that span a wide range of areas such as integrating the NAV system with other software applications like Microsoft Office, creating reports to present information from multiple areas of the system, and so on. You will not only learn the basics of NAV programming, but you will also be exposed to the technologies that surround the NAV system such as .NET programming, SQL Server, and Web Services.

The first half of the cookbook will help programmers using NAV for the first time by walking them through the building blocks of writing code and creating objects such as tables, forms, and reports.

The second half focuses on using the technologies surrounding NAV to build better solutions. You will learn how to write .NET code that works with the NAV system and how to integrate the system with other software applications such as Microsoft Office or even custom programs. You will also discover some of the features of the RoleTailored client including creating pages and custom add-ins.

What this book covers

Chapter 1, Strings, Dates, and Other Data Types, covers the processes involved in working with most common, simple data types. You will learn how to convert data into different data types as well as some of the basic NAV functions that can be used to control the data stored in those variables. Each recipe is accompanied by base NAV code so that you can see how these building blocks are used to create the full application.

Chapter 2, General Development, focuses on the traditional code structures native to most programming languages. These structures include loops, conditional statements, functions, and so on. You will also learn some commands that are found exclusively in C/AL including ones that allow you to create your own progress bars and how to reference dynamic data.

Chapter 3, Working with Tables and Records, discusses the many things that can be done with the database in NAV. You will learn how to create table structures to hold business data, such as fields and keys, and how to filter that data to return only what you wish to see. Additionally, you will find out how to retrieve data from other companies and rollback any data changes that may have been committed to the database.

Chapter 4, Designing Forms, shows you how to create displays that will allow your users to interact with the data. You will learn how to create several different types of forms including matrixes and wizards and to customize its look and feel.

Chapter 5, Report Design, focuses on displaying data from multiple sources to your users. You will learn how to group data and display totals, and create reports that only process data. There are also recipes that will teach you how to make reports look more professional with tools such as watermarks and page counts.

Chapter 6, Diagnosing Code Problems, explains how to use built-in NAV tools such as Debugger and Client Monitor to find problems in your code. You will also learn techniques for structuring your code so that you can bypass any errors that might occur.

Chapter 7, Roles and Security, covers setting up user roles and permissions. You will learn several methods that will let you interact with the NAV security system and different ways to restrict user access to data such as field-level security and overriding the Zoom window. Integration with Active Directory is also discussed.

Chapter 8, Leveraging Microsoft Office, describes different methods to integrate with the Microsoft Office suite of products. These include Word, Excel, InfoPath, Communicator (instant messenger), and Visio. Many of these recipes require you to build .NET automation classes that will be used within the NAV client.

Chapter 9, OS Interaction, focuses on different ways to integrate with the Windows operating system. There are several recipes to replace deprecated functions from versions prior to NAV 2009. You will learn how to search the file system as well as how to directly query the system registry.

Chapter 10, Integration, explains different methods by which NAV can interact with outside applications. You will learn how to exchange flat files with Dataports and XMLports, write your own .NET classes which can be used in NAV, and access data directly from other systems. The new Web Services features in NAV 2009 are also discussed.

Chapter 11, Working with SQL Server, provides an introduction to the SQL Server environment. There recipes will help you understand SIFT (Sum Index Field Technology), to use SQL Views as data in NAV, and to call NAV code from a SQL Job.

Chapter 12, The RoleTailored Client, covers many of the new features found in NAV 2009. You will learn the basics of creating pages, Role Centers, and report layouts. In addition, you will learn how to write your own .NET add-in to display data from outside sources directly in the NAV client.

What you need for this book

Used in the recipes: NAV 2009 SP1, Visual Studio 2008, SQL Server 2008.

Most recipes will work with: NAV 5.0, Visual Studio 2005, SQL Server 2005.

Who this book is for

If you are a junior/entry level NAV developer then the first half of the book is designed primarily for you. You may or may not have any programming experience. This book focuses on the basics of NAV programming. It would be best if you have gone through a brief introduction to the NAV client.

If you are a mid-level NAV developer, you will find the second half more useful. These chapters explain how to think outside the NAV box when building solutions. Senior developers will find these recipes useful too.

Conventions

In this book, you will find a number of styles of text that distinguish between different kinds of information. Here are some examples of these styles, and an explanation of their meaning.

Code words in text are shown as follows: "The sp_who command queries the sys.sysprocesses system table in SQL."

A block of code is set as follows:

Window.OPEN('Customer No: #1####################');
Window.INPUT(1, CustomerNo);
Window.CLOSE;
IF Customer.GET(CustomerNo) THEN
MESSAGE('Customer Name: %1', Customer.Name)
ELSE
MESSAGE('No customer found!);

Any command-line input or output is written as follows:


"Path to Application Server\nassql" debug, appservername="NAS",
servername="Your Server Name", database="Your Database
Name",company="Your Company Name", startupparameter="NEP-", objectcache=
32000, nettype=tcp

New terms and important words are shown in bold. Words that you see on the screen, in menus or dialog boxes for example, appear in the text like this: "From the NAV client menu, click on Tools | Debugger | Code Coverage."

Note

Warnings or important notes appear in a box like this.

Tip

Tips and tricks appear like this.

Reader feedback

Feedback from our readers is always welcome. Let us know what you think about this book — what you liked or may have disliked. Reader feedback is important for us to develop titles that you really get the most out of.

To send us general feedback, simply send an e-mail to , and mention the book title via the subject of your message.

If there is a book that you need and would like to see us publish, please send us a note in the SUGGEST A TITLE form on www.packtpub.com or e-mail .

If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide on www.packtpub.com/authors.

Customer support

Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.

Note

Downloading the example code for this book

You can download the example code files for all Packt books you have purchased from your account at http://www.PacktPub.com. If you purchased this book elsewhere, you can visit http://www.PacktPub.com/support and register to have the files e-mailed directly to you.

Errata

Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books maybe a mistake in the text or the code we would be grateful if you would report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/support, selecting your book, clicking on the errata submission form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded on our website, or added to any list of existing errata, under the Errata section of that title. Any existing errata can be viewed by selecting your title from http://www.packtpub.com/support.

Piracy

Piracy of copyright material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works, in any form, on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.

Please contact us at with a link to the suspected pirated material.

We appreciate your help in protecting our authors, and our ability to bring you valuable content.

Questions

You can contact us at if you are having a problem with any aspect of the book, and we will do our best to address it.