Programming Microsoft® Dynamics™ NAV Create, modify, and maintain applications in NAV 5.0, the latest version of the ERP application formerly known as Navision David Studebaker BIRMINGHAM - MUMBAI Programming Microsoft® Dynamics™ NAV Copyright © 2007 Packt Publishing All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews. Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, Packt Publishing, nor its dealers or distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book. Packt Publishing has endeavored to provide trademark information about all the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information. First published: October 2007 Production Reference: 2121007 Published by Packt Publishing Ltd. 32 Lincoln Road Olton Birmingham, B27 6PA, UK. ISBN 978-1-904811-74-9 www.packtpub.com Cover Image by David Studebaker ([email protected]) Credits Author Project Manager David Studebaker Patricia Weir Reviewers Project Coordinator Luc Van Dyck Abhijeet Deobhakta Mark Brummel Indexer Senior Acquisition Editor Bhushan Pangaonkar Douglas Paterson Proofreader Development Editor Chris Smith Mithil Kulkarni Production Coordinators Technical Editors Shantanu Zagade Nilesh Kapoor Manjiri Nadkarni Divya Menon Kushal Sharma Cover Designer Shantanu Zagade Editorial Manager Dipali Chittar Foreword In 1986 the Navision founders Jesper Balser, Torben Wind, and Peter Bang were looking back on the successful release of their first product “PC-Plus”. It was the first easy-to-use accounting package for the IBM PC on the Danish market. It immediately picked up a huge market share and the founders started thinking about how to expand the business. They decided to try to sell a vertical solution for auto-repair shop spare-part management—but they were immediately flooded with requests from potential customers who wanted to have the product tailored exactly to meet their needs. Because of this they decided to get out of the customization business, thus enabling partners to do the customization while providing them with the right tools. PC-Plus used a database, which was based on the ISAM database, which Anders Hejlsberg wrote as a sample program for his Pascal compiler. However the database was not multiuser and if the power went, data could easily get corrupted. Other database alternatives were either too expensive or of poor quality, so they decided to write their own database. The result of this was the Navision product, which had a rich set of tools for modifying the business application and a robust multiuser version-based database. The product became a huge success with a rapidly growing number of partners, who recognized a big business opportunity, and customers, who could have the product tailor-made to fulfill the specific needs of their businesses. The Windows version of Navision was released in 1995 and became part of the Windows revolution. The rest is history: the company went international, went public, and in 2002 was acquired by Microsoft. I joined Navision in 1987 and have been a part of this amazing journey. Today as part of Microsoft, the team and I have started a new journey with the product now called Microsoft Dynamics NAV and will bring the product to the .net platform. Next, we will introduce a new role-tailored client, enabling us to reach even more partners and customers moving forward. Michael Nielsen, Director of Engineering, Microsoft Dynamics NAV About the Author David Studebaker is currently a Principal of Liberty Grove Software, Inc., with his partner Karen Studebaker. Liberty Grove Software provides development, consulting, training, and upgrade services for Microsoft Dynamics NAV resellers and firms using NAV internally. Liberty Grove Software is a Microsoft Certified Partner. David has been recognized by Microsoft three times as a Certified Professional for NAV—in Development, in Applications, and in Installation & Configuration. He is also a Certified Microsoft Trainer for NAV. He began developing with C/AL in 1996. David Studebaker has been programming since taking his first Fortran II course in 1962. In the fall of 1963 he took the first COBOL course taught at Purdue University, where the first U.S. computer science department was later created. The next spring, undergraduate student David was assigned to teach the graduate-level class. Since that time, David has been an active participant in each step of computing technology—from the early mainframes to today's technology, from binary assembly coding to C/AL. He has worked with over 40 different models and brands of computers, over a dozen operating systems, and over two dozen different programming languages. Special projects include the development of first production SPOOL system in 1967. In the decades following, David was project manager and lead developer for several commercially distributed business application systems. Application areas in which David has worked range from engineering to manufacturing to freight carriage to general accounting to public mass transit to banking to not-for-profit and association management to legal billing to distribution/inventory management to shop floor data collection and production management. David has a BS in Mechanical Engineering from Purdue University and an MBA from the University of Chicago, both with concentrations in Computer Science. David has been a computer operator, system programmer, application programmer, business analyst, consultant, service bureau operations manager, bureaucrat, teacher, project manager, trainer, documenter, software designer, mentor, writer, and entrepreneur. He has been partner or owner and manager of several computer systems businesses, while always maintaining a significant role as a business application developer. David's work with relational databases and 4th-generation languages with integrated development environments began in 1984. David assisted in script-writing for a series of audio training courses for early PC operating systems and wrote for a newsletter Computers in Education. A series of articles by David concerning the use of computer systems to track and help manage manufacturing shop floor operations were published in several trade and professional magazines. He was lead author of the Product Identification and Tracking section of the SME Tool and Manufacturing Handbook. For over ten years, David was a reviewer of business applications-related publications for Computing Reviews of the Association for Computing Machinery (ACM). David has been a member of the ACM since 1963 and was a founding officer of two local chapters of the ACM. About the Reviewers Luc Van Dyck is active as a software consultant and works for a Belgian Microsoft partner. He started working with Dynamics NAV in 1997 (at that time it was called Navision Financials 1.10). In the year 1999, he started the website http://myNavision.net to provide a forum and downloads for users of the Dynamics NAV ERP system. When Microsoft bought Navision Software A/S in 2002, the site was renamed to http://mibuso.com; mibuso.com is one of the largest on-line communities of Microsoft Dynamics professionals. This on-line community gives users and developers of products from the Microsoft Dynamics family (Navision, Axapta, CRM, Great Plains, ...) a place to exchange ideas and tools, and to find business partners and products. The website provides you with a forum where you can ask questions about the different Dynamics products. It also contains a large selection of downloads, in different categories (code examples, demo versions, webcasts, factsheets, tools, etc.). Microsoft partners can submit their company details to the Business Directory and publish their add-ons or factsheets in the Product Directory. In October 2004, he was awarded with the MVP status (Most Valuable Professional) by Microsoft, for his active participation in the Dynamics community. Mark Brummel is an all-round NAV expert. He started 10 years ago in 1997 as an end user, being an early adopter of the system. Two years later he started working for a local reseller and used his end-user perspective to develop add-ons for NAV. In the following years he has developed five major add-ons for three NAV partners and was involved in over a hundred implementations. Next to the development projects he has guided and trained both experienced consultants and young talent in becoming NAV experts. Because of his experience in all aspects of NAV implementations Mark started to specialize in escalation engineering. In the year 2006, he started his own company specialized in this field, helping both end-users and partners with problems. To share knowledge he writes articles and gives workshops. He also assists Microsoft at events like Tech Ed and Convergence and participates in product development. One of his special skills is performance-tuning of NAV systems, combining both technical and functional knowledge to establish better-running systems and happier end users. In the year 2006, Mark Brummel was rewarded with the MVP award by Microsoft. Table of Contents Preface 1 Chapter 1: The Basic Ingredients 11 Some Unique NAV Terms Defined 12 The C/SIDE Integrated Development Environment 13 Object Designer Tool Icons 14 Seven Kinds of NAV Objects 15 More Definitions (Related to NAV) 16 NAV Functional Terminology 18 Getting Started with Application Design 18 Tables 19 Example: Table Design 19 Example: Table Creation 20 Forms 22 Card Forms 23 Tabular Forms 24 Main/Sub Forms 24 Matrix Forms 25 Trendscape Forms 26 All Forms 27 Creating a Card Form 27 Creating a List Form 31 Reports 34 Creating a List Format Report 35 Codeunits 38 MenuSuites 39 Dataports 39 XMLports 40 Integration Tools 40 Backups and Documentation 41 Summary 42