Programming Microsoft Dynamics NAV - Marije Brummel - E-Book

Programming Microsoft Dynamics NAV E-Book

Marije Brummel

0,0
44,39 €

-100%
Sammeln Sie Punkte in unserem Gutscheinprogramm und kaufen Sie E-Books und Hörbücher mit bis zu 100% Rabatt.
Mehr erfahren.
Beschreibung

Microsoft Dynamics NAV is a full business solution suite, and a complete ERP solution, which contains a robust set of development tools to support customization and enhancement. These tools help in greater control over financials and can simplify supply chain, manufacturing, and operations.
This book will take you from an introduction to Dynamics NAV and its integrated development tools to being a productive developer in the Dynamics NAV Development Environment.

Das E-Book können Sie in Legimi-Apps oder einer beliebigen App lesen, die das folgende Format unterstützen:

EPUB

Seitenzahl: 729

Veröffentlichungsjahr: 2017

Bewertungen
0,0
0
0
0
0
0
Mehr Informationen
Mehr Informationen
Legimi prüft nicht, ob Rezensionen von Nutzern stammen, die den betreffenden Titel tatsächlich gekauft oder gelesen/gehört haben. Wir entfernen aber gefälschte Rezensionen.



Programming Microsoft Dynamics NAV

Programming Microsoft Dynamics NAV

Fifth Edition

 

Hone your skills and increase your productivity when programming in Microsoft Dynamics NAV 2017

          

Marije Brummel David A. Studebaker Christopher D. Studebaker

       

       BIRMINGHAM - MUMBAI

Programming Microsoft Dynamics NAV

Fifth Edition

Copyright © 2017 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(s), nor Packt Publishing, and its dealers and 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 of 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 Edition: October 2007 Second Edition: November 2009 Third Edition: February 2013 Fourth Edition: July 2015 Fifth published: April 2017

Production reference: 1190417

Published by Packt Publishing Ltd.
Livery Place
35 Livery Street
Birmingham 
B3 2PB, UK.

ISBN 978-1-78646-819-2

www.packtpub.com

Credits

Authors

Marije Brummel David Studebaker Christopher Studebaker

Copy Editor

 

Zainab Bootwala

Reviewer

 

Alex Chow

Project Coordinator

 

Prajakta Naik

Commissioning Editor

 

Aaron Lazar

Proofreader

 

Safis Editing

Acquisition Editor

 

Nitin Dasan

Indexer

 

Mariammal Chettiyar

Content Development Editor

 

Siddhi Chavan

Production Coordinator

 

Nilesh Mohite

Technical Editor

 

Dhiraj Chandanshive

Foreword

In this age where almost any piece of information can be found on the internet, it might seem obsolete to come around with the book that's in front of you. Hundreds of pages of information on what a developer would, and I personally think should, like to know about developing in Dynamics NAV, dozens of useful technical tips and tricks, best practices, and a load of references to more, a great asset to any Dynamics NAV development team, and even more. And this is what makes this book something far beyond all the information out there. This book integrates technical Dynamics NAV with functional Dynamics NAV. On contrary to many other technical platforms, Dynamics NAV is first and foremost an ERP platform serving thousands of customers around the world. Any developer with an ambition to start programming  Microsoft Dynamics NAV cannot but become an expert in the functional side of it.

Being the first ever author to have written an independent book on how to program Dynamics NAV, Dave Studebaker became a valuable resource to many and a trendsetter in our community in the late days of his professional live. With the new rhythm of major releases by Microsoft, Dave, and his co-author, and son, Chris, managed to keep his sibling evolve with the subject it covered so eloquently. Now, a decade after the first version of this book, with NAV on the verge of a major development experience change, Dave has called upon some helping hands from the other side of the Atlantic. Both Marije Brummel and I were honored to be included in this project. Thanks for having us in, Dave and Chris.

And thank you reader for buying this book. May it be as valuable to you as was to many before you.

Luc van Vugt

Microsoft MVP and Co-Founder of NAV-Skills

About the Authors

Marije Brummel is a teacher and evangelist for Microsoft Dynamics NAV, focused in helping partners and end users of the product.

Author, programmer, consultant, project manager, presenter, evangelist, salesperson, and a trainer. Marije Brummel has worked for Partners, ISVs, End Users, Master VARs, and Microsoft across the globe in more than 25 countries.

It’s next to impossible to find someone as widely and deeply experienced as Marije in the Business Central community. She has received numerous awards including the Microsoft MVP award and the NAVUG All-Star. She was chair of the Dynamics Credentialling committee and authored the official Microsoft Exam materials. She did both onsite and online readiness sessions for Microsoft when the product went through major changes, such as moving from two-tier to three-tier and the introduction of extensions.

Her biggest passion is changing the world for the better in every way possible. One of her biggest achievements was the introduction of Design Patterns into the Business Central community. She is the go-to girl when it comes to performance troubleshooting and upgrade challenges. Technologies such as the Azure stack and Web frameworks don’t hold secrets in regards to Business Central.

Marije has written many books and countless blog articles and YouTube videos, which influenced almost every person and project involved with Business Central. At home, she enjoys the outdoors with her dog and tries to spend as much time as possible with her kids and family. She likes shopping and traveling.

David Studebaker has been a software consulting entrepreneur and manager most of his career while always maintaining a significant role as an application developer. David has been designing, developing, and teaching software since 1962. He has been a founding partner in five software service firms, most recently Studebaker Technology and Liberty Grove Software. Among his special achievements was the design and development of the very first production SPOOL system, a 1967 AT&T / IBM joint project.

David has been writing for publication since his college days. His published writings include a decade of technical reviews for the ACM’s Computing Reviews and a variety of articles and reference material on shop floor data collection. David is the author of four other Packt books on programming in Dynamics NAV C/AL, two of which were co-authored with Christopher Studebaker.

David has a BS in Mechanical Engineering from Purdue University and an MBA from the University of Chicago. He is a life member of the Association for Computing Machinery and was a founding officer of two ACM chapters.

Christopher Studebaker has worked as a NAV Developer / Implementer since 1999. He has experience designing, developing, implementing, and selling in the NAV and SQL Server environments, specializing in retail, manufacturing, job shop, and distribution implementations, mostly in high user-count, high data volume applications.

Chris has worked on many NAV implementations with integrations to external databases and third-party add-on products. Some special applications have included high volume order entry, pick-to-light systems, point of sale, procurement analysis, and web front ends.

Chris acts in a consulting and training role for customers and for peer NAV professionals. He provides training both in informal and classroom situations, often developing custom course material to support courses tailored to specific student group needs. Courses have included various NAV functional and development areas. Chris was a co-author of two previous books on programming in NAV C/AL.

Before becoming a certified NAV developer, Chris was a certified environmental consultant. His duties included regulatory reporting, data analysis, project management, and subcontractor oversight in addition to managing projects for hazardous material management and abatement.

Chris is a Microsoft Certified IT Professional, SQL database developer, as well as a Microsoft Certified Business Solutions Professional in NAV Development and NAV Installation and Configuration. He has a Bachelor of Science degree from Northern Illinois University and has done graduate work at Denmark Technical University.

Chris was a co-author of the Packt books, Programming Microsoft Dynamics NAV 2013 and Programming Microsoft Dynamics NAV 2015.

About the Reviewer

Alex Chow has been working with Microsoft Dynamics NAV, formerly Navision, since 1999. Over the years, Alex has conducted hundreds of implementations across multiple industries. His customers range from $2 million a year small enterprises to $500 million a year multinational corporations.

Over the course of his Dynamics NAV career, he has often been designated as the primary person responsible for the success and failure of a Dynamics NAV implementation. The fact that Alex is still in the Dynamics NAV business means that he’s been pretty lucky so far. His extensive career in the Dynamics NAV business is evidence of his success rate and expertise.

With a background in implementing all functions and modules both in and outside of Microsoft Dynamics NAV, Alex has encountered and resolved the most practical to the most complex requirements and business rules. Through these experiences, he has learned that sometimes you have to be a little crazy to have a competitive edge.

Believing that sharing these experience and knowledge would benefit the Dynamics NAV community, Alex writes about his journey at www.dynamicsnavconsultant.com. He is also the founder of AP Commerce, Inc. (www.apcommerce.com) in 2005, a full service Dynamics NAV service center. In addition, Alex has written two books about Dynamics NAV titled Getting Started with Dynamics NAV 2013 Application Development and Implementing Microsoft Dynamics NAV - Third Edition, both by Packt.

Alex lives in Southern California with his beautiful wife and two lovely daughters. He considers himself the luckiest man in the world.

www.PacktPub.com

For support files and downloads related to your book, please visit www.PacktPub.com.

Did you know that Packt offers eBook versions of every book published, with PDF and ePub files available? You can upgrade to the eBook version at www.PacktPub.com and as a print book customer, you are entitled to a discount on the eBook copy. Get in touch with us at [email protected] for more details.

At www.PacktPub.com, you can also read a collection of free technical articles, sign up for a range of free newsletters and receive exclusive discounts and offers on Packt books and eBooks.

https://www.packtpub.com/mapt

Get the most in-demand software skills with Mapt. Mapt gives you full access to all Packt books and video courses, as well as industry-leading tools to help you plan your personal development and advance your career.

Why subscribe?

Fully searchable across every book published by Packt

Copy and paste, print, and bookmark content

On demand and accessible via a web browser

Customer Feedback

Thanks for purchasing this Packt book. At Packt, quality is at the heart of our editorial process. To help us improve, please leave us an honest review on this book's Amazon page at https://www.amazon.com/dp/1786468190.

If you'd like to join our team of regular reviewers, you can e-mail us at [email protected]. We award our regular reviewers with free eBooks and videos in exchange for their valuable feedback. Help us be relentless in improving our products!

Acknowledgments

Marije Brummel

This book is the result of working with Microsoft Dynamics NAV® for almost 20 years and having had many discussions, debates, and even arguments with other people who are as passionate about the product as I am.

Being an early adopter of the software, I was very fortunate to be able to make many mistakes during my career and learn from them each time. Fundamental questions such as variable naming, user interface, and where to write code were all discussed many times and changed over the years.

Like many developers, I feel like a creative artist that needs to put his signature on his work. Unfortunately, this does not go well when writing solutions for Microsoft Dynamics NAV. When adopting the style of the base application, you will find that collaboration becomes easier and people will understand your efforts better than when you create your own style.

During the years I worked with the product, I've come to appreciate the structure of the base application. At a certain point in my career, I made an assumption that many of you might recognize. I started to treat what was done in the core product as "always correct".

In the past ten years, ever since I received my first MVP award, I got closer to the development team and was fascinated by the way the product was created and how issues are prioritized. I heard many stories from people who worked on the product in the early 90ies and started to realize that the core product is written by developers just like me and that many of the core components were acquired from partners who had their own development styles.

Over the years, I felt the core NAV product became 'polluted' and code was written in a less structured way, both by Microsoft and by NAV partners. Between 2006 and 2010, my core business was performance troubleshooting and upgrades. The code I saw in that period motivated me to write my first book about Application Design. This was my first effort to document the way Microsoft Dynamics NAV is designed and how application areas work together.

Special thanks go to two very important mentors I've had in my professional career –David Studebaker and Michael Nielsen. Dave and his wife Karen are very special friends and their knowledge and wisdom have been very important. Very often when I discuss an idea with Dave, he says things like, "Yes we did that in 1973 with Cobol." Michael has been my guardian angel at Microsoft for a decade, and now my colleague at ForNAV and personal friend.

I hope this book will inspire you, as it did me, to write software in a generic style that others will recognize and find easy to work with.

I'd also like to thank the reviewers as mentioned in the book but also Luc van Vugt who unofficially helped me with this book.

Last, but definitely not least, I want to thank my wife Dionel and my kids Josefien, Wesley, Saskia, and Daan. Thank you for allowing me to spend time writing these books and travel to the events where I can talk to others about this.

                                                                                                              

David Studebaker

I offer unbounded appreciation to Karen, my spouse and partner in both life and work, for your unflagging love, support, patience and encouragement in all ways.

Thank you to my co-authors, Marije Brummel and Christopher Studebaker, without whom this book would not have been possible. I am very fortunate to get to work with such knowledgeable experts as you, who are each special to me in your own way.

Thank you to Rebecca and Christopher, my children of whom I am very proud for your own achievements, for your love and support, and for your parenting of my wonderful grandchildren Alec, CeCe and Cole, who are the future.

Special thanks to Michael Nielsen of Microsoft for your wholehearted support of this and my previous four Programming NAV books. Many thanks to Marije Brummel, who knows more about NAV than almost anyone (except maybe Michael), for generously sharing your knowledge.

Thank you to all the people at Microsoft and Packt, as well as our technical reviewers and others, who assisted us with their contributions and advice (especially Luc van Vugt).

Family and friends are what make life worthwhile. All my life, I have had the benefit of inspiration, affection, and help from so many people. Thank you all.

                                                                                                       

Christopher Studebaker

First and foremost, I would like to thank my parents, Karen and David Studebaker, for giving me the opportunity to start in the NAV world and allowing me the room to grow on my own. Of course, I could not have participated in this book if it weren't for my wife, Beth. Having worked within the NAV community for the past decade, I have worked with many wonderful people, most notably, my parents (of course), Betty Cronin, Kathy Nohr, Tommy Madsen, Susanne Priess, David Podjasek, Joy Bensur , Diane Beck, Chris Pashby, and Anthony Fairclough. Without them, I would not have been the NAV professional I am today.                                                                                                      

                                                                                                       

Table of Contents

Preface

A brief history of NAV

The beginning

Single user PC Plus

Multi-user Navigator

Navision Financials for Windows

Growth and Mergers

Continuous enhancement

C/AL's Roots

What you should know

What this book covers

What you need for this book

Who this book is for

Conventions

Reader feedback

Customer support

Downloading the example code

Errata

Piracy

Questions

Introduction to NAV 2017

NAV 2017 - An ERP system

Financial management

Manufacturing

Supply chain management

Business Intelligence and reporting

Artificial Intelligence

Relationship Management

Human resource management

Project management

A developer's overview of NAV 2017

NAV object types

The C/SIDE Integrated Development Environment

Object Designer tool icons

C/AL programming language

NAV object and system elements

NAV functional terminology

User Interface

Hands-on development in NAV 2017

NAV 2017 development exercise scenario

Getting started with application design

Application tables

Designing a simple table

Creating a simple table

Pages

Standard elements of pages

List pages

Card pages

Document pages

Journal/Worksheet pages

Creating a List page

Creating a Card page

Creating some sample data

Creating a list report

Other NAV object types

Codeunits

Queries

MenuSuites

XMLports

Development backups and documentation

Review questions

Summary

Tables

An overview of tables

Components of a table

Naming tables

Table numbering

Table properties

Table triggers

Keys

SumIndexFields

Field Groups

Bricks

Enhancing our sample application

Creating and modifying tables

Assigning a table relation property

Assigning an InitValue property

Adding a few activity-tracking tables

New tables for our WDTU project

New list pages for our WDTU project

Keys, SumIndexFields, and TableRelations in our examples

Secondary keys and SumIndexFields

Table Relations

Modifying an original NAV table

Version List documentation

Types of table

Fully Modifiable tables

Master Data

Journal

Template

Entry tables

Subsidiary (Supplementary) tables

Register

Posted Document

Singleton

Temporary

Content Modifiable tables

System table

Read-Only tables

Virtual

Review questions

Summary

Data Types and Fields

Basic definitions used in NAV

Fields

Field properties

Field triggers

Field events

Data structure examples

Field numbering

Field and variable naming

Data types

Fundamental data types

Numeric data

String data

Date/Time data

Complex data types

Data structure

Objects

Automation

Input/Output

DateFormula

References and other data types

Data type usage

FieldClass property options

FieldClass - Normal

FieldClass - FlowField

FieldClass - FlowFilter

FlowFields and a FlowFilter for our application

Filtering

Experimenting with filters

Accessing filter controls

Development Environment filter access

Role Tailored Client filter access

Review questions

Summary

Pages - the Interactive Interface

Page Design and Structure Overview

Page Design guidelines

NAV 2017 Page structure

Types of pages

Role Center page

List page

Card page

Document page

FastTabs

ListPlus page

Worksheet (Journal) page

Confirmation Dialog page

Standard Dialog page

Navigate page

Navigate function

Special pages

Request page

Departments page

Page parts

FactBox Area

CardParts and ListParts

Charts

Chart Part

Chart Control Add-In

Page names

Page Designer

New Page wizard

Page Components

Page Triggers

Page properties

Page Preview Tool

Inheritance

WDTU Page Enhancement - part 1

Page Controls

Control types

Container controls

Group controls

Field controls

Page Part controls

Page Control triggers

Bound and Unbound Pages

WDTU Page Enhancement - part 2

Page Actions

Page Action types and subtypes

Action Groups

Navigation Pane Button actions

Actions Summary

Learning more

Patterns and creative plagiarism

Experimenting on your own

Experimentation

Review questions

Summary

Queries and Reports

Queries

Building a simple Query

Query and Query Component properties

Query properties

DataItem properties

Column properties

Reports

What is a report?

Four NAV report designers

NAV report types

Report types summarized

Report naming

Report components - overview

Report Structure

Report Data overview

Report Layout overview

Report data flow

Report components - detail

C/SIDE Report Properties

Visual Studio - Report Properties

Report triggers

Request Page Properties

Request Page Triggers

DataItem properties

DataItem triggers

Creating a Report in NAV 2017

Learn by experimentation

Report building - Phase 1

Report building - Phase 2

Report building - Phase 3

Modifying an existing report with Report Designer or Word

Runtime rendering

Inheritance

Interactive report capabilities

Interactive sorting

Interactive Visible / Not Visible

Request Page

Add a Request Page option

Processing-Only reports

Creative report plagiarism and Patterns

Review questions

Summary

Introduction to C/SIDE and C/AL

Understanding C/SIDE

Object Designer

Starting a new object

Accessing the Table Designer screen

Accessing the Page Designer

Accessing the Report Dataset Designer

Accessing the Codeunit Designer

Query Designer

XMLport Designer

MenuSuite Designer

Object Designer Navigation

Exporting objects

Importing objects

Import Table object changes

Text objects

Shipping changes as an extension

Some useful practices

Changing data definitions

Saving and compiling

Some C/AL naming conventions

Variables

C/AL Globals

C/AL Locals

Special working storage variables

C/SIDE programming

Non-modifiable functions

Modifiable functions

Custom functions

Creating a function

C/AL syntax

Assignment and punctuation

Expressions

Operators

Arithmetic operators and functions

Boolean operators

Relational operators and functions

Precedence of operators

Frequently used C/AL functions

MESSAGE function

ERROR function

CONFIRM function

STRMENU function

Record functions

SETCURRENTKEY function

SETRANGE function

SETFILTER function

GET function

FIND Functions

FIND ([Which]) options and the SQL Server alternates

Conditional statements

BEGIN-END compound statement

IF-THEN-ELSE statement

Indenting code

Some simple coding modifications

Adding field validation to a table

Adding code to a report

Lay out the new Report Heading

Saving and testing

Lookup related table data

Laying out the new report Body

Saving and testing

Handling user entered report options

Defining the Request Page

Finishing the processing code

Testing the completed report

Output to Excel

Review questions

Summary

Intermediate C/AL

C/AL Symbol Menu

Internal documentation

Source code management

Validation functions

TESTFIELD

FIELDERROR

INIT

VALIDATE

Date and Time functions

TODAY, TIME, and CURRENTDATETIME

WORKDATE

DATE2DMY function

DATE2DWY function

DMY2DATE and DWY2DATE functions

CALCDATE

Data conversion and formatting functions

ROUND function

FORMAT function

EVALUATE function

FlowField and SumIndexField functions

CALCFIELDS function

SETAUTOCALCFIELDS function

CALCSUMS function

CALCFIELDS and CALCSUMS comparison

Flow control

REPEAT-UNTIL

WHILE-DO

FOR-TO or FOR-DOWNTO

CASE-ELSE statement

WITH-DO statement

QUIT, BREAK, EXIT, and SKIP

QUIT function

BREAK function

EXIT function

SKIP function

Input and Output functions

NEXT function with FIND or FINDSET

INSERT function

MODIFY function

Rec and xRec

DELETE function

MODIFYALL function

DELETEALL function

Filtering

SETFILTER function

COPYFILTER and COPYFILTERS functions

GETFILTER and GETFILTERS functions

FILTERGROUP function

MARK function

CLEARMARKS function

MARKEDONLY function

RESET function

InterObject communication

Communication through data

Communication through function parameters

Communication via object calls

Enhancing the WDTU application

Modify table fields

Adding validation logic

Playlist Header validations

Creating the Playlist Subpage

Playlist Line validations

Creating a function for our Factbox

Creating a Factbox Page

Review questions

Summary

Advanced NAV Development Tools

NAV process flow

Initial Setup and Data Preparation

Transaction entry

Testing and Posting the Journal batch

Utilizing and maintaining the data

Data maintenance

Role Center pages

Role Center structure

Role Center activities page

Cue Groups and Cues

Cue source table

Cue Group Actions

System Part

Page Parts

Page Parts Not Visible

Page Part Charts

Page Parts for User Data

Navigation Pane and Action Menus

Action Designer

Creating a WDTU Role Center Ribbon

Action Groups / Ribbon Categories

Configuration/Personalization

Navigation Pane

Navigation Home Button

Navigation Departments Button

Other Navigation Buttons

XMLports

XMLport components

XMLport properties

XMLport triggers

XMLport data lines

The XMLport line properties

SourceType as Text

SourceType as Table

SourceType as Field

Element or Attribute

NodeType of Element

NodeType of Attribute

XMLport line triggers

DataType as Text

DataType as Table

DataType as Field

XMLport Request Page

Web services

Exposing a web service

Publishing a web service

Enabling web services

Determining what was published

XMLport - Web Services Integration example for WDTU

Review questions

Summary

Successful Conclusions

Creating new C/AL routines

Callable functions

Codeunit 358 - DateFilterCalc

Codeunit 359 - Period Form Management

FindDate function

NextDate function

CreatePeriodFormat function

Codeunit 365 - Format Address

Codeunit 396 - NoSeriesManagement

Function models to review and use

Management codeunits

Multi-language system

Multi-currency system

Navigate

Modifying for Navigate

Debugging in NAV 2017

Text Exports of Objects

Dialog function debugging techniques

Debugging with MESSAGE and CONFIRM

Debugging with DIALOG

Debugging with text output

Debugging with ERROR

The NAV 2017 Debugger

Activating the Debugger

Attaching the Debugger to a Session

Creating Break Events

The Debugger window

Ribbon Actions:

Changing code while debugging

C/SIDE Test-Driven Development

Other interfaces

Automation Controller

Linked Data Sources

NAV Application Server

Client Add-ins

Client Add-in construction

WDTU Client Add-in

Client Add-in comments

Creating an Extension

Table Changes

Page Changes

Events

Creating a WDTU extension

Step 1 - Load PowerShell

Step 2 - Create Delta files

Step 3 - Manifest XML file

Remembering the App ID

Step 4 - Create the NAVx package

Installing the Extension

Publishing an Extension

Verification

Extension installation and setup

Customizing Help

NAV development projects - general guidance

Knowledge is key

Data-focused design

Defining the required data views

Designing the data tables

Designing the user data access interface

Designing the data validation

Data design review and revision

Designing the Posting processes

Designing the supporting processes

Double-check everything

Design for efficiency

Disk I/O

Locking

Updating and Upgrading

Design for updating

Customization project recommendations

One change at a time

Testing

Database testing approaches

Testing in production

Using a testing database

Testing techniques

Deliverables

Finishing the project

Plan for upgrading

Benefits of upgrading

Coding considerations

Good documentation

Low-impact coding

Supporting material

Review questions

Summary

Preface

Welcome to the worldwide community ofMicrosoft Dynamics NAV developers. This is a collegial environment populated by C/AL developers who readily and generously share their knowledge. There are formal and informal organizations of NAV-focused users, developers, and vendor firms scattered around the globe and active on the Web. Our community continues to grow and prosper--now including over 110,000 user companies worldwide.

The information in this book will help you shorten your learning curve on how to program for the NAV 2017 ERP system using the C/AL language, the C/SIDE integrated development environment, and their capabilities. We hope you enjoy working with NAV as much as we have.

A brief history of NAV

Each new version of Microsoft Dynamics NAV is the result of inspiration and hard work along with some good fortune and expert technical investment over the last thirty years.

The beginning

Three college friends, Jesper Balser, Torben Wind, and Peter Bang, from Denmark Technical University (DTU) founded their computer software business in 1984 when they were in their early twenties; that business was Personal Computing &  Consulting (PC & C), and its first product was called PC Plus.

Single user PC Plus

PC Plus was released in 1985 with a primary goal of ease of use. An early employee said its functional design was inspired by the combination of a manual ledger journal, an Epson FX 80 printer, and a Canon calculator. Incidentally, Peter Bang is the grandson of one of the founders of Bang & Olufsen, the manufacturer of home entertainment systems par excellence.

PC Plus was PC DOS-based, a single user system. PC Plus' design features included the following:

An interface resembling the use of documents and calculators

Online help

Good exception handling

Minimal computer resources required

The PC Plus product was marketed through dealers in Denmark and Norway.

Multi-user Navigator

In 1987, PC & C released a new product, the multi-user Navigator, and a new corporate name, Navision. Navigator was quite a technological leap forward. It included the following:

Client/Server technology

Relational database

Transaction-based processing

Version management

High-speed OLAP capabilities (SIFT technology)

A screen painter tool

A programmable report writer

In 1990, Navision was expanding its marketing and dealer recruitment efforts into Germany, Spain, and the United Kingdom. Also in 1990, V3 of Navigator was released. Navigator V3 was still a character-based system, albeit a very sophisticated one. If you had an opportunity to study Navigator V3.x, you would instantly recognize the roots of today's NAV product. By V3, the product included:

A design based on object-oriented concepts

Integrated 4GL Table, Form, and Report Design tools (the IDE)

Structured exception handling

Built-in resource management

The original programming language that became C/AL

Function libraries

The concept of regional or country-based localization

When Navigator V3.5 was released, it also included support for multiple platforms and multiple databases. Navigator V3.5 would run on both Unix and Windows NT networks. It supported Oracle and Informix databases as well as the one developed in-house.

At about this time, several major strategic efforts were initiated. On the technical side, the decision was made to develop a GUI-based product. The first prototype of Navision Financials (for Windows) was shown in 1992. At about the same time, a relationship was established that would take Navision into distribution in the United States. The initial release in the US in 1995 was V3.5 of the character-based product, rechristened Avista for US distribution.

Navision Financials for Windows

In 1995, Navision Financials V1.0 for Microsoft Windows was released. This product had many (but not all) of the features of Navigator V3.5. It was designed for complete look-and-feel compatibility with Windows 95. There was an effort to provide the ease of use and flexibility of development of Microsoft Access. The new Navision Financials was very compatible with Microsoft Office and was thus sold as "being familiar to any Office user". Like any V1.0 product, it was quickly followed by a much improved V1.1.

In the next few years, Navision continued to be improved and enhanced. Major new functionalities, such as the following, were added:

Contact Relation Management (CRM)

Manufacturing (ERP)

Advanced Distribution (including Warehouse Management)

Various Microsoft certifications were obtained, providing muscle to the marketing efforts. Geographic and dealer-based expansion continued apace. By 2000, according to the Navision Annual Report of that year, the product was represented by nearly 1,000 dealers (Navision Solution Centers) in 24 countries and used by 41,000 customers located in 108 countries.

Growth and Mergers

In 2000, Navision Software A/S, and its primary Danish competitor, Damgaard A/S, merged. Product development and new releases continued for the primary products of both original firms (Navision and Axapta). In 2002, the now much larger Navision Software, with all its products (Navision, Axapta, and the smaller, older C5, and XAL) was purchased by Microsoft, becoming part of the Microsoft Business Systems division along with the previously purchased Great Plains Software business, and its several product lines. The Navision and Great Plains products all received a common rebranding as the Dynamics product line. Navision was renamed Dynamics NAV.

Continuous enhancement

As early as 2003, research began with the Dynamics NAV development team, planning moves to further enhance NAV and taking advantage of various parts of the Microsoft product line. Goals were defined to increase integration with products such as Microsoft Office and Microsoft Outlook. Goals were also set to leverage the functional capabilities of Visual Studio and SQL Server, among others. All the while, there was a determination not to lose the strength and flexibility of the base product.

NAV 2009 was released in late 2008, NAV 2013 in late 2012, followed by NAV 2015 in late 2014. NAV2017, the version on which this book is based, was released in October 2016. The biggest hurdles to the new technologies have been cleared. A new user interface, the Role Tailored Client, was created as part of this renewal. NAV was tightly integrated with Microsoft’s SQL Server and other Microsoft products, such as Office, Outlook, and SharePoint.  Development is more integrated with Visual Studio and is more .NET compliant. The product is becoming more open and, at the same time, more sophisticated, supporting features such as Web Services access, Web and tablet clients, integration of third-party controls, RDLC and Word based reporting, and so on

Microsoft continues to invest in, enhanced and advanced NAV. More new capabilities and features are yet to come, continuing to build on the successes of the past. We all benefit.

C/AL's Roots

One of the first questions asked by people new to C/AL is often "what other programming language is it like?" The best response is "Pascal". If the questioner is not familiar with Pascal, the next best response would be "C" or "C#".

At the time the three founders of Navision were attending classes at Denmark Technical University (DTU), Pascal was in wide use as a preferred language not only in computer courses, but in other courses where computers were tools and software had to be written for data analyses. Some of the strengths of Pascal as a tool in an educational environment also served to make it a good model for Navision's business applications development.

Perhaps coincidentally (perhaps not) at DTU in this same time period, a Pascal compiler called Blue Label Pascal was developed by Anders Hejlsberg; that compiler became the basis for what was Borland's Turbo Pascal, which was the "everyman's compiler" of the 1980s because of its low price. Anders went with his Pascal compiler to Borland. While he was there, Turbo Pascal morphed into the Delphi language and IDE tool set  under his guidance.

Anders later left Borland and joined Microsoft, where he led the C# design team. Much of the NAV-related development at Microsoft is now being done in C#. So, the Pascal-C/AL-DTU connection has come full circle, only now it appears to be C#-C/AL. Keeping it in the family, Anders' brother, Thomas Hejlsberg also works at Microsoft on NAV as a software architect. Each in their own way, Anders and Thomas continue to make significant contributions to Dynamics NAV.

In a discussion about C/AL and C/SIDE, Michael Nielsen of Navision and Microsoft, who developed the original C/AL compiler, runtime, and IDE, said that the design criteria were to provide an environment that could be used without the following:

Dealing with memory and other resource handling

Thinking about exception handling and state

Thinking about database transactions and rollbacks

Knowing about set operations (SQL)

Knowing about OLAP (SIFT)

Paraphrasing some of Michael's additional comments, goals of the language and IDE designs were to :

Allowing the developer to focus on design, not coding, but still allow flexibility

Providing a syntax based on Pascal stripped of complexities, especially, relating to memory management

Providing a limited set of predefined object types and reducing the complexity and learning curve

Implementing database versioning for a consistent and reliable view of the database

Making the developer and end user more at home by borrowing a large number of concepts from Office, Windows, Access, and other Microsoft products

Michael is now a co-founder and partner at ForNAV. Michael and his fellow team members are all about developing high quality reporting enhancements for Dynamics NAV with the goal of making working with reports easy. Another example of how, once part of the NAV community, most of us want to stay part of that community.

What you should know

To get the maximum out of this book as a developer, you should have the following attributes:

Be an experienced developer

Know more than one programming language

Have IDE experience

Be knowledgeable about business applications

Be good at self-directed study

If you have these attributes, this book will help you become productive with C/AL and NAV much more rapidly.

Even though this book is targeted first at developers, it is also designed to be useful to executives, consultants, managers, business owners, and others who want to learn about the development technology and operational capabilities of Dynamics NAV. If you fit in one of these, or similar, categories, start by studying Chapter 1 for a good overview of NAV and its tools. Then, you should review sections of other chapters as the topics apply to your specific areas of interest.

This book's illustrations are from the W1 Cronus database Dynamics NAV V2017.

What this book covers

Chapter 1,  Introduction to NAV 2017 , starts with an overview of NAV as a business application system, which is followed by an introduction to the seven types of NAV objects, and the basics of C/AL and C/SIDE. Then, we will do some hands-on work, defining Tables, multiple Page types, and a Report. We’ll close with a brief discussion of how backups and documentations are handled in C/SIDE.

Chapter 2, Tables, focuses on the foundation level of NAV data structure: Tables and their structures. We will cover Properties, Triggers (where C/AL resides), Field Groups, Table Relations, and SumIndexFields. We’ll work our way through hands-on creation of several tables in support of our example application. We will also review the types of tables found in the NAV applications.

Chapter 3, Data Types and Fields, teaches you about fields, the basic building blocks of NAV data structure. We will review the different Data Types in NAV and cover all the field properties and triggers in detail, as well as review the three different Field Classes. We’ll conclude with a discussion about the concept of filtering and how it should be considered in database structure design.

Chapter 4, Pages - the Interactive Interface, reviews the different types of pages, their structures (Triggers, Properties), and general usage. We’ll build several pages for our example application using the Page Wizard and Page Designer. We will also study the different types of controls that can be used in pages. In addition, we’ll review how and where actions are added to pages.

Chapter 5, Queries and Reports, teaches you about both Queries and Reports--two methods of extracting data for presentation to users. For Queries, we will study how they are constructed and some of the ways they are utilized. For Reports, we will walk through report data flow and the variety of different report types. We will study the two Report Designers, the C/SIDE Report Designer and the Visual Studio Report Designer and how a NAV report is constructed using both of these. We’ll learn what aspects of reports use one designer and what aspects use the other. As in previously studied objects, we will discuss Properties and Triggers. We will review how reports can be made interactive and will do some hands-on report creation.

Chapter 6, Introduction to C/SIDE and C/AL, explains general Object Designer Navigation as well as the individual Designers (Table, Page, Report). We’ll study C/AL code construction, syntax, variable types, expressions, operators, and functions. We will then take a closer look at some of the more frequently used built-in functions. This chapter will wrap up with an exercise adding some C/AL code to a report objects created in an earlier exercise.

Chapter 7, Intermediate C/AL, digs deeper into C/AL development tools and techniques. We will review some more advanced built-in functions, including those relating to dates and decimal calculations, both critical business application tools. We’ll study C/AL functions that support process flow control functions, input/output, and filtering. Then, we’ll do a review of methods of communication between objects. Finally, we’ll apply some of what we’ve learned to enhance our example application.

Chapter 8,  Advanced NAV Development Tools, reviews some of the more important elements of the Role Tailored User Experience; in particular, the Role Center Page construction. We will dig into the components of a Role Center Page and how to build one. We’ll also cover two of the powerful ways of connecting NAV applications to the world outside of NAV, XMLports, and Web Services. To better understand these, we will not only review their individual component parts, but we will go through the hands-on effort of building an example of each one.

Chapter 9, Successful Conclusions, gives you a detailed study of how NAV functions are constructed and teaches you how to construct your own functions. We will learn more about tools and features built into C/AL and C/SIDE. We will study the new debugger, review the support for Test-Driven Development, and take a look at the ability to integrate .NET Client Add-ins and integrate a .NET Add-in into our example applications. Finally, we will review tips for design efficiency, updating, and upgrading the system, all with the goal of helping us become more productive, high quality NAV developers.

What you need for this book

You will need some basic tools, including at least the following:

A license and database that you can use for development experimentation. The ideal license is a full Developer's license. If your license only contains the Page, Report, and Table Designer capabilities, you will still be able to do many of the exercises, but you will not have access to the inner workings of Pages and Tables and the C/AL code contained therein.

A copy of the NAV Cronus demo/test database for your development testing and study. It would be ideal if you also had a copy of a production database at hand for examination as well. This book's illustrations are from the W1 Cronus database for V2017.

The hardware and software requirements for installing and running Microsoft Dynamics NAV can be found at

https://msdn.microsoft.com/en-us/dynamics-nav/system-requirements-for-microsoft-dynamics-nav

.

Access to other NAV manuals, training materials, websites, and experienced associates will obviously be of benefit, but they are not required for the time with this book to be a good investment.

Who this book is for

This book is for:

The business applications software designer/developer who:

Wants to become productive in NAV C/SIDE—C/AL development as quickly as possible

Understands business applications and the type of software required to support those applications

Has significant programming experience

Has access to a copy of NAV 2017, including at least the Designer granules and a standard Cronus demo database

Is willing to do the exercises to get hands-on experience

The Reseller manager or executive who wants a concise, in-depth view of NAV's development environment and tool set

The technically knowledgeable manager or executive of a firm using NAV that is about to embark on a significant NAV enhancement project

The technically knowledgeable manager or executive of a firm considering purchase of NAV as a highly customizable business applications platform

The experienced business analyst, consultant, or advanced student of applications software development who wants to learn more about NAV because it is one of the most widely used, most flexible business application systems available

The reader of this book:

Does not need to be an expert in object-oriented programming

Does not need previous experience with NAV, C/AL, or C/SIDE

Conventions

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

Code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles are shown as follows: "The Customer table would be filtered to report only customers who have an outstanding balance greater than zero."

A block of code is set as follows:

CalculateNewDate;"Date Result" := CALCDATE("Date Formula to Test","Reference Date for Calculation");

New terms and important words are shown in bold. Words that you see on the screen, for example, in menus or dialog boxes, appear in the text like this: "Click on Preview to see the Report display onscreen."

Warnings or important notes appear in a box like this.
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 disliked. Reader feedback is important for us as it helps us develop titles that you will really get the most out of. To send us general feedback, simply e-mail [email protected], and mention the book's title in the subject of your message. 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 at 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.

Downloading the example code

You can download the example code files for this book 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.

You can download the code files by following these steps:

Log in or register to our website using your e-mail address and password.

Hover the mouse pointer on the

SUPPORT

tab at the top.

Click on

Code Downloads & Errata

.

Enter the name of the book in the

Search

box.

Select the book for which you're looking to download the code files.

Choose from the drop-down menu where you purchased this book from.

Click on

Code Download

.

Once the file is downloaded, please make sure that you unzip or extract the folder using the latest version of:

WinRAR / 7-Zip for Windows

Zipeg / iZip / UnRarX for Mac

7-Zip / PeaZip for Linux

The code bundle for the book is also hosted on GitHub at https://github.com/PacktPublishing/Programming-Microsoft-Dynamics-NAV-Fifth-Edition. We also have other code bundles from our rich catalog of books and videos available at https://github.com/PacktPublishing/. Check them out!

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 could 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/submit-errata, 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 to our website or added to any list of existing errata under the Errata section of that title.

To view the previously submitted errata, go to https://www.packtpub.com/books/content/support and enter the name of the book in the search field. The required information will appear under the Errata section.

Piracy

Piracy of copyrighted 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 [email protected] 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

If you have a problem with any aspect of this book, you can contact us at [email protected], and we will do our best to address the problem.

Introduction to NAV 2017

"Time changes all things; there is no reason why language should escape this universal law."                                                                                                          - Ferdinand de Saussure
"When we use a language, we should commit ourselves to knowing it, being able to read it, and writing it idiomatically."                                                                                                             - Ron Jeffries

Microsoft Dynamics NAV has one of the largest installed user bases of any enterprise resource planning (ERP) system serving over 100,000 companies and one million plus individual users at the time of this writing. The community of supporting organizations, consultants, implementers, and developers continues to grow and prosper. The capabilities of the off-the-shelf product increase with every release. The selection of the add-on products and services expands both in variety and depth.

The release of Microsoft Dynamics NAV 2017 continues its 20+ year history of continuous product improvement. It provides more user options for access and output formatting. For new installations, NAV 2017 includes tools for rapid implementation. For all installations, it provides enhanced business functionality and more support for ERP computing in the cloud, including integration with Microsoft Office 365.

NAV 2017 is also the base foundation for Microsoft Dynamics 365 for Financials, which is a cloud-based subset of the product that you can customize using extensions. We will discuss the concept of extensions in this book.

Our goal in this chapter is to gain a big picture understanding of NAV 2017. You will be able to envision how NAV can be used by the managers (or owners) of an organization to help manage activities and the resources, whether the organization is for-profit or not-for-profit. You will also be introduced to the technical side of NAV from a developer's point of view.

In this chapter, we will take a look at NAV 2017, including the following:

A general overview of NAV 2017

A technical overview of NAV 2017

A hands-on introduction to C/SIDE development in NAV 2017

NAV 2017 - An ERP system

NAV 2017 is an integrated set of business applications designed to service a wide variety of business operations. Microsoft Dynamics NAV 2017 is an ERP system. An ERP system integrates internal and external data across a variety of functional areas including manufacturing, accounting, supply chain management, customer relationships, service operations, and human resources management, as well as the management of other valued resources and activities. By having many related applications well integrated, a full featured ERP system provides an enter data once, use many ways information processing toolset.

NAV 2017 ERP addresses the following functional areas (and more):

Basic accounting functions (for example, general ledger, accounts payable, and accounts receivable)

Order processing and inventory (for example, sales orders, purchase orders, shipping, inventory, and receiving)

Relationship management (for example, vendors, customers, prospects, employees, and contractors)

Planning (for example, MRP, sales forecasting, and production forecasting)

Other critical business areas (for example, manufacturing, warehouse management, marketing, cash management, and fixed assets)

A good ERP system such as NAV 2017 is modular in design, which simplifies implementation, upgrading, modification, integration with third-party products, and expansion for different types of clients. All the modules in the system share a common database and, where appropriate, common data.

The groupings of individual NAV 2017 functions following is based on the Departments menu structure, supplemented by information from Microsoft marketing materials. The important thing is to understand the overall components that make up the NAV 2017 ERP system:

NAV 2017 has two quite different styles of user interface (UI). One UI, the development environment, targets developers. The other UI style, the RoleTailored client, targets end users. In NAV 2017, there are four instances of the RoleTailored client - for Windows, for web interaction, for tablet use, and a phone client, which was introduced in NAV 2016. The example images in the following module descriptions are from the RoleTailored client's Departments menu in the Windows client.

Financial management

Financial management is the foundation of any ERP system. No matter what the business is, the money must be kept flowing, and the flow of money must be tracked. The tools that help to manage the capital resources of the business are part of NAV 2017's Financial Management module. These include all or part of the following application functions:

General ledger - managing overall finances of the firm

Cash management and banking - managing inventory of money

Accounts receivable - tracking incoming revenue

Accounts payable - tracking outgoing funds

Analytical accounting - analyzing various flows of funds

Inventory and fixed assets - managing inventories of goods and equipment

Multi-currency and multi - language-supporting international business activities

The Financial Management section of the Departments menu is as follows:

Manufacturing

NAV 2017 manufacturing is general-purpose enough to be appropriate for Make to Stock (MTS), Make to Order (MTO), and Assemble to Order (ATO), as well as various subsets and combinations of those. Although off-the-shelf NAV is not particularly suitable for most process manufacturing and some of the very high volume assembly line operations, there are third-party add-on and add-in enhancements available for these applications. As with most of the NAV application functions, manufacturing can be implemented to be used in a basic mode or as a full featured system. NAV manufacturing includes the following functions:

Product design (BOMs and routings) - managing the structure of product components and the flow of manufacturing processes

Capacity and supply requirements planning - tracking the intangible and tangible manufacturing resources

Production scheduling (infinite and finite), execution, and tracking quantities and costs, plus tracking the planned use manufacturing resources, both on an unconstrained and constrained basis

The Manufacturing section of the Departments menu is as follows:

Supply chain management

Obviously, some of the functions categorized as part of NAV 2017 supply chain management (SCM), for example, sales and purchasing) are actively used in almost every NAV implementation. The supply chain applications in NAV include all or parts of the following applications:

Sales order processing and pricing - supporting the heart of every business

Purchasing (including Requisitions) - planning, entering, pricing, and processing purchase orders

Inventory management - managing inventories of goods and materials

Warehouse management including receiving and shipping - managing the receipt, storage, retrieval, and shipment of material and goods in warehouses

Even though we might consider Assembly part of Manufacturing, the standard NAV 2017 Departments menu includes it in the Warehouse section:

As a whole, these functions constitute the base components of a system appropriate for distribution operations, including those that operate on an ATO basis.

Business Intelligence and reporting

Although Microsoft marketing materials identify Business Intelligence (BI) and reporting as though it were a separate module within NAV, it's difficult to physically identify it as such. Most of the components used for BI and reporting purposes are (appropriately) scattered throughout various application areas. In the words of one Microsoft document, Business Intelligence is a strategy, not a product. Functions within NAV that support a BI strategy include the following:

Standard reports - distributed ready-to-use by end users

Account schedules and analysis reports - a specialized report writer for

General Ledger

data

Query, XMLport and Report designers - developer tools to support the creation of a wide variety of report formats, charts, and XML and CSV files

Analysis by dimensions - a capability embedded in many of the other tools

Interfaces into Microsoft Office and Microsoft Office 365 including Excel-communications of data either into NAV or out of NAV

RDLC report viewer - provides the ability to present NAV data in a variety of textual and graphic formats, including user interactive capabilities

Interface capabilities such as DotNet interoperability and web services - technologies to support interfaces between NAV 2017 and external software products

NAV 2017 has standard packages for

Power BI

, both integrated on the role center as well as dashboards

Artificial Intelligence

A new feature of NAV 2017 is integration with Cortana intelligence, which is used for forecasting. The algorithms used in Artificial Intelligence (AI) can be used to give users extra information to make business decisions.

Relationship Management

NAV's Relationship Management (RM) functionality is definitely the little sister (or, if you prefer, little brother) of the fully featured standalone Microsoft CRM system and the new Dynamics 365 for Sales and Dynamics 365 for Marketing. The big advantage of NAV RM is its tight integration with NAV customer and sales data. With NAV 2016, Microsoft introduced a new way of integrating with CRM using OData.

Also falling under the heading of the customer relationship module is the NAV Service Management (SM