You are previewing Microsoft Dynamics NAV 2009 Programming Cookbook.
O'Reilly logo
Microsoft Dynamics NAV 2009 Programming Cookbook

Book Description

Build better business applications with NAV

  • Write NAV programs to do everything from finding data in a table to integration with an instant messenger client

  • Develop your own .NET code to perform tasks that NAV cannot handle on its own

  • Work with SQL Server to create better integration between NAV and other systems

  • Learn to use the new features of the NAV 2009 Role Tailored Client

  • Easy-to-read recipes with detailed explanations and images

  • Maximize your learning with short tutorials that tell you exactly what you need to know without all of the fluff

  • In Detail

    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.

    A set of to-the-point tutorials to quickly teach you what you need to know about NAV Programming

    Table of Contents

    1. Microsoft Dynamics NAV 2009 Programming Cookbook
      1. Microsoft Dynamics NAV 2009 Programming Cookbook
      2. Credits
      3. About the author
      4. About the reviewer
      5. Preface
        1. What this book covers
        2. What you need for this book
        3. Who this book is for
        4. Conventions
        5. Reader feedback
        6. Customer support
          1. Errata
          2. Piracy
          3. Questions
      6. 1. Strings, Dates, and Other Data Types
        1. Introduction
        2. Retrieving the system date and time
          1. How to do it...
          2. How it works...
          3. There's more...
            1. Logging changes and events
          4. See also
        3. Retrieving the work date
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
            1. Populating date fields when a document is created
          5. See also
        4. Determining the day, month, and year from a given date
          1. How to do it...
          2. How it works...
          3. There's more...
            1. Determining depreciation
          4. See also
        5. Converting a value to a formatted string
          1. How to do it...
          2. How it works...
          3. There's more...
            1. Creating filters using other variable types
          4. See also
        6. Creating an array
          1. How to do it...
          2. How it works...
          3. There's more...
            1. Creating an address using the format address codeunit
          4. See also
        7. Creating an Option variable
          1. How to do it...
          2. How it works...
          3. There's more...
            1. Using Options in documents
          4. See also
        8. Converting a string to another data type
          1. How to do it...
          2. How it works...
          3. There's more...
            1. Incrementing a number series
          4. See also
        9. Manipulating string contents
          1. How to do it...
          2. How it works...
          3. There's more...
            1. Linking records with strings
          4. See also
        10. Using date formulas to calculate dates
          1. How to do it...
          2. How it works...
          3. There's more...
            1. Calculating reminder terms using date formulas
          4. See also
      7. 2. General Development
        1. Introduction
        2. Repeating code using a loop
          1. How to do it...
          2. How it works...
          3. There's more...
            1. Using a WHILE loop
            2. Using a REPEAT..UNTIL loop
          4. See also
        3. Displaying a Progress Bar
          1. How to do it...
          2. How it works...
          3. There's more...
            1. Processing only reports
          4. See also
        4. Checking for conditions using an IF statement
          1. How to do it...
          2. How it works...
          3. There's more...
            1. Testing multiple conditions
          4. See also
        5. Using a CASE statement to test multiple conditions
          1. How to do it...
          2. How it works...
          3. There's more...
          4. See also
        6. Creating a function
          1. How to do it...
          2. How it works...
          3. There's more...
            1. Creating local or private functions
          4. See also
        7. Passing parameters by reference
          1. How to do it...
          2. How it works...
          3. There's more...
          4. See also
        8. Referencing dynamic tables and fields
          1. How to do it...
          2. How it works...
          3. There's more...
          4. See also
        9. Using recursion
          1. How to do it...
          2. How it works...
          3. There's more...
          4. See also
      8. 3. Working with Tables and Records
        1. Introduction
        2. Creating a table
          1. How to do it...
          2. How it works...
          3. There's more...
          4. See also
        3. Adding a key to a table
          1. How to do it...
          2. How it works...
          3. See also
        4. Creating transactions to alter data
          1. How to do it...
          2. How it works...
          3. There's more...
            1. Calling code when performing a transaction
            2. Catching errors when performing a transaction
          4. See also
        5. Validating data
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
          5. See also
        6. Retrieving a single record from the database
          1. How to do it...
          2. How it works...
          3. See also
        7. Using advanced filtering
          1. How to do it...
          2. How it works...
          3. There's more...
          4. See also
        8. Retrieving data using FIND
          1. How to do it...
          2. How it works...
          3. There's more...
          4. See also
        9. Adding a FlowField to a table
          1. How to do it...
          2. How it works...
          3. There's more...
            1. Determining the value of a FlowField
          4. See also
        10. Creating a SumIndex field
          1. How to do it...
          2. How it works...
          3. There's more...
          4. See also
        11. Marking records for future use
          1. How to do it...
          2. How it works...
          3. There's more...
          4. See also
        12. Clearing filters, keys, and values
          1. How to do it...
          2. How it works...
          3. See also
        13. Using temporary tables to store data
          1. How to do it...
          2. How it works...
          3. There's more...
            1. Storing records to process
          4. See also
        14. Retrieving data from another company
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. See also
        15. Merging records
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. See also
        16. Writing your own rollback routine
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. See also
      9. 4. Designing Forms
        1. Introduction
        2. Obtaining input without a form
          1. How to do it...
          2. How it works...
          3. There's more...
          4. See also
        3. Using the Form Generation Wizard
          1. How to do it...
          2. How it works...
          3. There's more...
          4. See also
        4. Changing text appearance
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
          5. See also
        5. Preventing editable lookup forms
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
          5. See also
        6. Adding an editable field to a non-editable form
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. See also
        7. Creating a matrix form
          1. How to do it...
          2. How it works...
          3. See also
        8. Creating a wizard-style form
          1. How to do it...
          2. How it works...
          3. See also
        9. Designing a form based on a temporary table
          1. How to do it...
          2. How it works...
          3. See also
        10. Updating a subform from a parent form
          1. How to do it...
          2. How it works...
          3. See also
        11. Updating a parent form from a subform
          1. How to do it...
          2. How it works...
          3. See also
      10. 5. Report Design
        1. Introduction
        2. Using the Report Generation Wizard
          1. How to do it...
          2. How it works...
          3. There's more...
          4. See also
        3. Adding custom filters to the request form
          1. How to do it...
          2. How it works...
          3. There's more...
          4. See also
        4. Setting filters when a report is loaded
          1. How to do it...
          2. How it works...
          3. There's more...
          4. See also
        5. Creating a report to process data
          1. How to do it...
          2. How it works...
          3. There's more...
          4. See also
        6. Displaying a check mark on a report
          1. How to do it...
          2. How it works...
          3. See also
        7. Dynamically showing Sections on reports
          1. How to do it...
          2. How it works...
          3. There's more...
          4. See also
        8. Grouping data to display totals
          1. How to do it...
          2. How it works...
          3. There's more...
          4. See also
        9. Adding page totals to reports
          1. How to do it...
          2. How it works...
          3. There's more...
        10. Display page X of Y
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
          5. See also
        11. Using virtual tables to loop through data
          1. How to do it...
          2. How it works...
          3. There's more...
            1. List of virtual tables in NAV
          4. See also
        12. Adding a watermark to a page
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
          5. See also
      11. 6. Diagnosing Code Problems
        1. Introduction
        2. Using the debugger
          1. How to do it...
          2. How it works...
          3. There's more...
          4. See also
        3. Setting breakpoints
          1. How to do it...
          2. How it works...
          3. There's more...
          4. See also
        4. Using Code Coverage
          1. How to do it...
          2. How it works...
          3. There's more...
            1. Running Code Coverage from code
        5. Handling runtime errors
          1. How to do it...
          2. How it works...
          3. See also
        6. Using Client Monitor to diagnose problems
          1. How to do it...
          2. How it works...
          3. See also
        7. Finding errors when using NAS
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
          5. See also
        8. Implementing Try / Catch / Finally
          1. How to do it...
          2. How it works...
          3. There's more...
          4. See also
      12. 7. Roles and Security
        1. Introduction
        2. Adding roles through the User Setup table
          1. How to do it...
          2. How it works...
          3. There's more...
          4. See also
        3. Creating and assigning a security role
          1. How to do it...
          2. How it works...
          3. There's more...
            1. Leveraging the User Rights tool
          4. See also
        4. Using FILTERGROUP to restrict data
          1. How to do it...
          2. How it works...
          3. See also
        5. Checking for user-assigned roles
          1. How to do it...
          2. How it works...
          3. See also
        6. Checking Active Directory groups
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. See also
        7. Using security filters
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
          5. See also
        8. Field-level security
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
          5. See also
        9. Assigning menu suites based on company
          1. How to do it...
          2. How it works...
          3. See also
        10. Ending an idle session
          1. How to do it...
          2. How it works...
          3. There's more...
        11. Automatically adding users to NAV
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
          5. See also
        12. Hiding values in Zoom
          1. How to do it...
          2. How it works...
          3. There's more...
          4. See also
      13. 8. Leveraging Microsoft Office
        1. Introduction
        2. Using the style sheet tool
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
          5. See also
        3. Sending data to Microsoft Word
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
          5. See also
        4. Sending an e-mail from NAV through Outlook
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
            1. Sending an HTML formatted e-mail
        5. Exporting data using the Excel buffer
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
          5. See also
        6. Creating a data connection from Excel to NAV
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
          5. See also
        7. Creating an InfoPath form with NAV data
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
          5. See also
        8. Instant messaging using Office Communicator
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
          5. See also
        9. Creating charts with Visio
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
          5. See also
      14. 9. OS Interaction
        1. Introduction
        2. Using HYPERLINK to open external files
          1. How to do it...
          2. How it works...
          3. There's more...
          4. See also
        3. Working with environment variables
          1. How to do it...
          2. How it works...
          3. There's more...
            1. ENVIRON for the RoleTailored client
          4. See also
        4. Using SHELL to run external applications
          1. How to do it...
          2. How it works...
          3. See also
        5. Browsing for a file
          1. How to do it...
          2. How it works...
          3. See also
        6. Browsing for a folder
          1. How to do it...
          2. How it works...
          3. See also
        7. Checking file and folder access permissions
          1. How to do it...
          2. How it works...
          3. See also
        8. Querying the registry
          1. How to do it...
          2. How it works...
          3. There's more...
          4. See also
        9. Zipping folders and files within NAV
          1. How to do it...
          2. How it works...
          3. See also
      15. 10. Integration
        1. Introduction
        2. Flat file exchange using dataports
          1. How to do it...
          2. How it works...
          3. There's more...
          4. See also
        3. Sharing information through XMLports
          1. How to do it...
          2. How it works...
          3. There's more...
          4. See also
        4. Manually writing to and reading from files
          1. How to do it...
          2. How it works...
          3. There's more...
          4. See also
        5. Creating a web service
          1. How to do it...
          2. How it works...
          3. See also
        6. Consuming web services
          1. How to do it...
          2. How it works...
          3. See also
        7. Sending data through FTP
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
          5. See also
        8. Printing reports to PDF
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
          5. See also
        9. Creating a custom NAS handler
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. See also
        10. Writing your own automation using C#
          1. How to do it...
          2. How it works...
          3. See also
        11. Using ADO to access outside data
          1. How to do it...
          2. How it works...
          3. There's more...
      16. 11. Working with SQL Server
        1. Introduction
        2. Creating a basic SQL query
          1. How to do it...
          2. How it works...
          3. There's more...
            1. Other Types of SQL queries
          4. See also
        3. Adding the xp_ stored procedures
          1. How to do it...
          2. See also
        4. Understanding SIFT tables
          1. How to do it...
          2. How it works...
          3. See also
        5. Using SQL Profiler
          1. How to do it...
          2. How it works...
          3. See also
        6. Displaying data from a SQL view in NAV
          1. How to do it...
          2. How it works...
          3. There's more...
          4. See also
        7. Figuring out who is blocking whom
          1. How to do it...
          2. How it works...
          3. There's more...
            1. Another way to find deadlocks
          4. See also
        8. Setting up a backup plan
          1. How to do it...
          2. How it works...
          3. See also
        9. Scheduling NAV tasks from SQL Server
          1. How to do it...
          2. How it works...
          3. There's more...
          4. See also
      17. 12. The RoleTailored Client
        1. Introduction
        2. Creating a page using the Page Generation Wizard
          1. How to do it...
          2. How it works...
          3. There's more...
          4. See also
        3. Building a Role Center
          1. How to do it...
          2. How it works...
          3. There's more...
          4. See also
        4. Changing default filter columns
          1. How to do it...
          2. How it works...
          3. There's more...
          4. See also
        5. Building the report layout
          1. How to do it...
          2. How it works...
          3. There's more...
          4. See also
        6. Interactive sorting for reports
          1. How to do it...
          2. How it works...
          3. There's more...
          4. See also
        7. Displaying a graph on a report
          1. How to do it...
          2. How it works...
          3. There's more...
          4. See also
        8. Displaying a .NET add-in on a page
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. See also