microsoft gp 10(vstdgpprogrammersguide)

Upload: atif-rehman

Post on 07-Apr-2018

231 views

Category:

Documents


2 download

TRANSCRIPT

  • 8/6/2019 Microsoft GP 10(VSTDGPProgrammersGuide)

    1/120

    Visual Studio Tools for Microsoft Dynamics GP

    Programmers Guide

    Release 10

  • 8/6/2019 Microsoft GP 10(VSTDGPProgrammersGuide)

    2/120

    Copyright Copyright 2008 Microsoft Corporation. All rights reserved.

    Complying with all applicable copyright laws is the responsibility of the user. Without limiting the

    rights under copyright, no part of this document may be reproduced, stored in or introduced into

    a retrieval system, or transmitted in any form or by any means (electronic, mechanical,

    photocopying, recording, or otherwise), or for any purpose, without the express written

    permission of Microsoft Corporation. Notwithstanding the foregoing, the licensee of the softwarewith which this document was provided may make a reasonable number of copies of this

    document solely for internal use.

    Trademarks Microsoft, Dexterity, Microsoft Dynamics, Visual Basic, Visual Studio, Windows, Windows Server,and Windows Vista are either registered trademarks or trademarks of Microsoft Corporation or its

    affiliates in the United States and/or other countries.

    The names of actual companies and products mentioned herein may be trademarks or registered

    marks - in the United States and/or other countries - of their respective owners.

    Unless otherwise noted, the example companies, organizations, products, domain names, e-mail

    addresses, logos, people, places, and events depicted herein are fictitious. No association with

    any real company, organization, product, domain name, e-mail address, logo, person, place, or

    event is intended or should be inferred.

    Intellectual property Microsoft may have patents, patent applications, trademarks, copyrights, or other intellectualproperty rights covering subject matter in this document. Except as expressly provided in any

    written license agreement from Microsoft, the furnishing of this document does not give you any

    license to these patents, trademarks, copyrights, or other intellectual property.

    Warranty disclaimer Microsoft Corporation disclaims any warranty regarding the sample code contained in thisdocumentation, including the warranties of merchantability and fitness for a particular purpose.

    Limitation of liability The content of this document is furnished for informational use only, is subject to change withoutnotice, and should not be construed as a commitment by Microsoft Corporation. Microsoft

    Corporation assumes no responsibility or liability for any errors or inaccuracies that may appear

    in this manual. Neither Microsoft Corporation nor anyone else who has been involved in the

    creation, production or delivery of this documentation shall be liable for any indirect, incidental,

    special, exemplary or consequential damages, including but not limited to any loss of anticipated

    profit or benefits, resulting from the use of this documentation or sample code.

    License agreement Use of this product is covered by a license agreement provided with the software product. If youhave any questions, please call the Microsoft Dynamics GP Customer Assistance Department at

    800-456-0025 (in the U.S. or Canada) or +1-701-281-6500.

    Publication date September 2008

  • 8/6/2019 Microsoft GP 10(VSTDGPProgrammersGuide)

    3/120

    P R O G R A M M E R S G U I D E

    Contents

    Introduction .................................................................................................................................................2

    Whats in this manual...................................................................................................................................2

    Whats new in this release of Visual Studio Tools....................................................................................2

    Prerequisites...................................................................................................................................................3Symbols and conventions ............................................................................................................................3

    Product support ............................................................................................................................................3

    Part 1: Getting Started .................................................................................................................6

    Chapter 1: SDK Installation ........................................................................................................ 7

    Installation procedure ..................................................................................................................................7

    Template registration....................................................................................................................................8

    What was installed........................................................................................................................................9

    Upgrading to Visual Studio 2008................................................................................................................9

    Chapter 2: Integration Basics..................................................................................................11

    What Visual Studio Tools provides ..........................................................................................................11

    Architecture .................................................................................................................................................11

    Creating a project ........................................................................................................................................12

    Chapter 3: Upgrading an Integration .............................................................................. 15

    C# integration..............................................................................................................................................15

    Visual Basic integration..............................................................................................................................17

    Part 2: Developing Integrations ...................................................................................20

    Chapter 4: WinForms ......................................................................................................................21Adding a Dynamics GP form to a project ...............................................................................................21

    WinForm properties....................................................................................................................................22

    Adding controls...........................................................................................................................................23

    Chapter 5: Control Reference ................................................................................................ 25

    Buttons..........................................................................................................................................................25

    TextBoxes......................................................................................................................................................27

    Labels ............................................................................................................................................................28

    ComboBoxes ................................................................................................................................................28

    ListBoxes ......................................................................................................................................................28

    Chapter 6: Dictionary Assembly Generator ..............................................................29

    Creating application assemblies ...............................................................................................................29

    Output files ..................................................................................................................................................29

    Using the Dictionary Assembly Generator .............................................................................................30

    Optimizing the assembly generating process.........................................................................................32

    Chapter 7: Accessing Dictionary Resources ............................................................ 33

    Adding references.......................................................................................................................................33

    Namespace...................................................................................................................................................34

  • 8/6/2019 Microsoft GP 10(VSTDGPProgrammersGuide)

    4/120

    ii P R O G R A M M E R S G U I D E

    C O N T E N T S

    Dictionary class ...........................................................................................................................................34

    Accessing additional resources.................................................................................................................35

    Variables for dictionary resources ............................................................................................................35

    Chapter 8: Events .............................................................................................................................. 37

    Registering events.......................................................................................................................................37

    Responding to events .................................................................................................................................39

    Chapter 9: Working with Tables...........................................................................................41

    Tables in Microsoft Dynamics GP.............................................................................................................41

    Table buffers.................................................................................................................................................42

    Opening and closing tables .......................................................................................................................43

    Keys...............................................................................................................................................................44

    Retrieving a row..........................................................................................................................................44

    Saving a row ................................................................................................................................................45

    Updating a row ...........................................................................................................................................46

    Removing a row..........................................................................................................................................47

    Table operation errors ................................................................................................................................48Ranges...........................................................................................................................................................49

    Row locking .................................................................................................................................................53

    Multiuser processing..................................................................................................................................53

    Chapter 10: Building and Deploying ................................................................................59

    Setting assembly information....................................................................................................................59

    Building an integration ..............................................................................................................................60

    Deploying an integration...........................................................................................................................61

    Chapter 11: Debugging................................................................................................................. 63

    Preparing to debug .....................................................................................................................................63

    Examining the application.........................................................................................................................64

    Disabling events..........................................................................................................................................64

    Chapter 12: Modified and Alternate Forms...............................................................65

    Modified forms............................................................................................................................................65

    Alternate forms ...........................................................................................................................................66

    Guidelines ....................................................................................................................................................67

    Part 3: Resource Reference ................................................................................................70

    Chapter 13: Forms............................................................................................................................. 71

    Accessing forms ..........................................................................................................................................71

    Form methods .............................................................................................................................................71

    Form properties...........................................................................................................................................73

    Form events .................................................................................................................................................74

    Chapter 14: Windows ..................................................................................................................... 75

    Accessing windows ....................................................................................................................................75

    Window methods........................................................................................................................................75

    Window properties .....................................................................................................................................75

    Window events............................................................................................................................................76

  • 8/6/2019 Microsoft GP 10(VSTDGPProgrammersGuide)

    5/120

    P R O G R A M M E R S G U I D E ii

    C O N T E N T S

    Chapter 15: Scrolling Windows ............................................................................................77

    Accessing scrolling windows....................................................................................................................77

    Scrolling window methods........................................................................................................................77

    Scrolling window properties.....................................................................................................................77

    Scrolling window events............................................................................................................................77

    Chapter 16: Window Fields.......................................................................................................

    81

    Accessing window fields ...........................................................................................................................81

    Window field methods...............................................................................................................................81

    Window field properties............................................................................................................................83

    Window field events...................................................................................................................................84

    Chapter 17: Tables ............................................................................................................................ 85

    Accessing tables ..........................................................................................................................................85

    Table methods..............................................................................................................................................86

    Table properties...........................................................................................................................................89

    Chapter 18: Table Fields .............................................................................................................. 91

    Accessing table fields .................................................................................................................................91

    Table field methods.....................................................................................................................................91

    Table field properties..................................................................................................................................92

    Chapter 19: Commands ............................................................................................................... 93

    Command types ..........................................................................................................................................93

    Accessing commands .................................................................................................................................93

    Command methods ....................................................................................................................................93

    Chapter 20: Globals .........................................................................................................................95

    Accessing globals ........................................................................................................................................95

    Global properties.........................................................................................................................................95

    Chapter 21: Procedures ............................................................................................................... 97

    Accessing global procedures.....................................................................................................................97

    Accessing form-level procedures..............................................................................................................97

    Procedure methods.....................................................................................................................................97

    Invokable procedures.................................................................................................................................98

    Chapter 22: Functions ................................................................................................................... 99

    Accessing global functions ........................................................................................................................99

    Accessing form-level functions.................................................................................................................99

    Function methods .....................................................................................................................................100

    Invokable functions ..................................................................................................................................100

    Part 4: Integration Examples ........................................................................................ 102

    Chapter 23: Field Defaulter ................................................................................................... 103

    Overview....................................................................................................................................................103

    Running the sample application.............................................................................................................103

    How Visual Studio Tools was used ........................................................................................................104

  • 8/6/2019 Microsoft GP 10(VSTDGPProgrammersGuide)

    6/120

    iv P R O G R A M M E R S G U I D E

    C O N T E N T S

    Chapter 24: Estimate Freight...............................................................................................105

    Overview....................................................................................................................................................105

    Running the sample application.............................................................................................................105

    How Visual Studio Tools was used ........................................................................................................106

    Glossary ..................................................................................................................................................... 109

    Index................................................................................................................................................................ 111

  • 8/6/2019 Microsoft GP 10(VSTDGPProgrammersGuide)

    7/120

  • 8/6/2019 Microsoft GP 10(VSTDGPProgrammersGuide)

    8/120

    2 P R O G R A M M E R S G U I D E

    Introduction

    Welcome to Visual Studio Tools for Microsoft Dynamics GP. This documentationexplains how to integrate applications you create with Visual Studio into MicrosoftDynamics GP. Before you begin creating an integration for Microsoft Dynamics GP,take a few moments to review the information presented here.

    Whats in this manual

    The Visual Studio Tools for Microsoft Dynamics GP Programmers Guide isdesigned to give you an in-depth understanding of how to use these tools to createan application that integrates with Microsoft Dynamics GP. Even if you are familiarwith using Visual Studio to develop applications, you will find it helpful to browsethe material presented here.

    Information is divided into the following parts:

    Part 1, Getting Started, explains how to install Visual Studio Tools for MicrosoftDynamics GP and begin creating an integration.

    Part 2, Developing Integrations, provides detailed information about creatingWinForms that match the Microsoft Dynamics GP appearance. Interacting withMicrosoft Dynamics GP through events is discussed. Building, deploying, anddebugging integrations are also addressed.

    Part 3, Resource Reference, provides detailed information about interactingwith the various types of resources in Microsoft Dynamics GP.

    Part 4, Integration Examples, describes example integrations that use VisualStudio Tools for Microsoft Dynamics GP.

    Whats new in this release of Visual Studio Tools

    Refer to the following list for more information about the new features added forthis release of Visual Studio Tools for Microsoft Dynamics GP.

    1. Table accessIntegrations created with Visual Studio Tools can now directly access tables inMicrosoft Dynamics GP without having to use another database accesstechnology such as ADO.NET. Refer to Chapter 9, Working with Tables, fordetails about accessing data in tables.

    2. Updated user interfaceThe user interface for forms created with Visual Studio Tools has been updated

    to match the new appearance of Microsoft Dynamics GP windows.

    3. Integrated runtimeThere is no longer a separate runtime installer for Visual Studio Tools forMicrosoft Dynamics GP. The runtime for Visual Studio Tools is now integratedinto the core Microsoft Dynamics GP product, and is available in everyinstallation.

    4. Support for Visual Studio 2005 and Visual Studio 2008You can use either Visual Studio 2005 or Visual Studio 2008 when creatingintegrations with Visual Studio Tools for Microsoft Dynamics GP.

  • 8/6/2019 Microsoft GP 10(VSTDGPProgrammersGuide)

    9/120

    P R O G R A M M E R S G U I D E 3

    I N T R O D U C T I O N

    Prerequisites

    You must be using Microsoft Dynamics GP 10. Since you will be working withMicrosoft Dynamics GP, knowledge of the accounting system will be helpfulConsult the Microsoft Dynamics GP documentation resources to learn more aboutthe product.

    You will also want to install the SDK for Microsoft Dynamics GP. The SDK isavailable in the Tools folder on the Microsoft Dynamics GP installation media. Itcontains useful information about Microsoft Dynamics GP, such as lists ofcommonly-used procedures and functions.

    To use Visual Studio Tools for Microsoft Dynamics GP, Visual Studio 2005 withService Pack 1 or Visual Studio 2008 is required. Earlier versions of Visual Studiocannot be used. It is assumed that you are familiar with programming in a managedlanguage such as C#. This documentation uses both C# and Visual Basic todemonstrate how to create integrations.

    Symbols and conventions

    To help you use this documentation more effectively, weve used the followingsymbols and conventions within the text to make specific types of informationstand out.

    Product support

    Microsoft Dynamics GP developer technical support can be accessed online or bytelephone. Go to www.microsoft.com/dynamics and click the CustomerSource orPartnerSource link, or call 888-477-7877 (in the US and Canada) or 701-281-0555.

    Symbol Description

    The light bulb symbol indicates helpful tips, shortcuts,and suggestions.

    Warnings indicate situations you should be aware ofwhen completing tasks.

    Margin notes summarize

    important information.

    Margin notes call attention to critical information anddirect you to other areas of the documentation wherea topic is explained.

    Convention Description

    Part 1, Getting Started Bold type indicates a part name.

    Chapter 5, Web Methods Quotation marks indicate a chapter name.

    Adding controls Italicized type indicates a section name.

    using System.IO; This font is used to indicate script examples.

    Dictionary AssemblyGenerator (DAG)

    Acronyms are spelled out the first time theyre used.

    TAB or ALT+M Small capital letters indicate a key or a key sequence.

    http://www.microsoft.com/dynamicshttp://www.microsoft.com/dynamics
  • 8/6/2019 Microsoft GP 10(VSTDGPProgrammersGuide)

    10/120

    4 P R O G R A M M E R S G U I D E

  • 8/6/2019 Microsoft GP 10(VSTDGPProgrammersGuide)

    11/120

  • 8/6/2019 Microsoft GP 10(VSTDGPProgrammersGuide)

    12/120

    6 P R O G R A M M E R S G U I D E

    Part 1: Getting StartedThis portion of the documentation describes how to get started creating anintegration using Visual Studio Tools for Microsoft Dynamics GP. The followingtopics are discussed:

    Chapter 1, SDK Installation, explains how to install Visual Studio Tools SDKfor Microsoft Dynamics GP.

    Chapter 2, Integration Basics, describes the architecture of a Visual StudioTools for Microsoft Dynamics GP integration. It also explains how to create aproject for a new integration.

    Chapter 3, Upgrading an Integration, explains how to upgrade an existingintegration to work with the current version of Visual Studio Tools for MicrosoftDynamics GP.

  • 8/6/2019 Microsoft GP 10(VSTDGPProgrammersGuide)

    13/120

    P R O G R A M M E R S G U I D E 7

    Chapter 1: SDK Installation

    The Visual Studio Tools for Microsoft Dynamics GP SDK contains the componentsneeded to create and build integrations. The following topics are discussed:

    Installation procedure Template registration What was installed Upgrading to Visual Studio 2008

    Installation procedure

    The Visual Studio Tools for Microsoft Dynamics GP SDK installer requires VisualStudio 2005 or Visual Studio 2008 to be installed first. For testing integrations, youwill also want Microsoft Dynamics GP installed.

    If you have installed an earlier version of the Visual Studio Tools SDK, be sure that youremove it from the system before you install the new version.

    To install the Visual Studio Tools for Microsoft Dynamics GP SDK, complete thefollowing procedure:

    1. Start the Visual Studio Tools SDK installer.

    Start the installer by running the VSToolsSDK.exe.

    2. View the welcome screen.

    Click Next to continue.

    3. Acknowledge the license agreement.

    Read and acknowledge the license agreement. Click Next to continue.

    4. Specify the features to install.

    Choose the features that will be installed:

    5. Specify the installation location.

    Use the default location, or choose another location. Click next to continue.

    Feature Description

    Visual Studio 2005 Templates The C# and Visual Basic templates for projects and

    forms. Visual Studio 2005 is required to install this

    feature.

    Visual Studio 2008 Templates The C# and Visual Basic templates for projects and

    forms. Visual Studio 2008 is required to install this

    feature.

    Documentation The Visual Studio Tools for Microsoft Dynamics GP

    Programmers Guide.

    Samples Sample integrations that demonstrate Visual Studio

    Tools.

    Assemblies and Assembly

    Generator

    The Dictionary Assembly Generator (Dag.exe) and

    the dictionary assemblies for the products that ship

    with Microsoft Dynamics GP. Also includes the

    IntelliSense XML files used by Visual Studio to

    display information about the resources accessed

    through the application assemblies.

  • 8/6/2019 Microsoft GP 10(VSTDGPProgrammersGuide)

    14/120

    P A R T 1 G E T T I N G S T A R T E D

    8 P R O G R A M M E R S G U I D E

    6. Begin the installation.

    Click Install to begin installing the SDK components.

    During the installation, Visual Studio must be reconfigured to recognize the newtemplates being installed. This process may take a few minutes to complete.

    7. Finish the installation.

    Click Finish to complete the installation.

    Template registration

    If you are running with limited user privileges or with User Account Control (UAC)active in Windows Vista the templates installed for Visual Studio Tools may not

    be registered in Visual Studio. You may need to manually register the templates sothey will appear as selections when you create new projects.

    To register the templates, perform the following command to have Visual Studio2005 re-create its template cache:

    C:\Program Files\Microsoft Visual Studio 8\Common7\IDE\devenv.exe /setup

    Use the following command for Visual Studio 2008 to re-create its template cache:

    C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\devenv.exe /setup

    On Windows Vista, you will need to set the properties of the devenv.exe applicationto be run with administrative privileges.

    On Windows Vista,

    choose to run devenv.exe

    as an administrator.

  • 8/6/2019 Microsoft GP 10(VSTDGPProgrammersGuide)

    15/120

    P R O G R A M M E R S G U I D E 9

    C H A P T E R 1 S D K I N S T A L L A T I O N

    What was installed

    The following items are installed for Visual Studio Tools for Microsoft Dynamics GPin the location you specified:

    If you chose to install them, the project templates for C# and Visual Basic will be inthe appropriate locations for Visual Studio.

    Upgrading to Visual Studio 2008

    If you have previously installed the Visual Studio Tools for Microsoft Dynamics GP10 SDK and want to upgrade from Visual Studio 2005 to Visual Studio 2008,complete the following procedure:

    1. Install Visual Studio 2008.

    2. Start the Visual Studio Tools SDK installer.

    Start the installer by running the VSToolsSDK.exe. The updated components forVisual Studio Tools will be installed.

    3. Close the installer.

    When the installer has finished updating components, click Finish.

    4. Change the Visual Studio Tools installation.

    In Add or Remove Programs (Windows XP or Windows Server 2003) orPrograms and Features (Windows Vista or Windows Server 2008) choose VisuaStudio Tools for Microsoft Dynamics GP 10.0 SDK. Click Change.

    Component Description

    VSTDGPReadme.rtf Contains late-breaking information about

    Visual Studio Tools for Microsoft DynamicsGP.

    VSTDGPProgrammersGuide.pdf Documentation for Visual Studio Tools.

    Samples.zip Sample Visual Studio projects that

    demonstrate Visual Studio Tools.

    Microsoft.Dexterity.Bridge.dll

    Microsoft.Dexterity.Shell.dll

    Microsoft.Dynamics.Framework.UI.Navigation.dll

    Microsoft.Dynamics.Framework.UI.WinForms.

    Controls.dll

    Core Microsoft Dynamics GP components

    used by Visual Studio Tools integrations.

    Dag.exe The Dictionary Assembly Generator, used to

    create application assemblies for application

    dictionaries and forms dictionaries.

    Bidi32.dllDdapi.dll

    Tntlib.dll

    Dex.dic

    Dex.ini

    Support files needed for Dag.exe

    Application Assemblies Assemblies that contain information about

    the resources in each dictionary that is

    shipped with Microsoft Dynamics GP. In

    addition to US English, other local versions

    of application assemblies are included.

    IntelliSense XML files Used by Visual Studio to display information

    about the corresponding application

    assembly.

  • 8/6/2019 Microsoft GP 10(VSTDGPProgrammersGuide)

    16/120

    P A R T 1 G E T T I N G S T A R T E D

    10 P R O G R A M M E R S G U I D E

    5. Add a new feature.

    Click Add/Remove Features to add a new feature to the Visual Studio Toolsinstallation.

    6. Install the Visual Studio 2008 templates.

    Mark the option to install the Visual Studio 2008 templates, and then click Next.Click Install to begin the installation process.

    7. Finish the installation.

    Click Finish to complete the installation.

  • 8/6/2019 Microsoft GP 10(VSTDGPProgrammersGuide)

    17/120

    P R O G R A M M E R S G U I D E 11

    Chapter 2: Integration Basics

    Before you create an integration using Visual Studio Tools for Microsoft DynamicsGP, it will be helpful to understand the basics of an integration. The following topicsare discussed:

    What Visual Studio Tools provides Architecture Creating a project

    What Visual Studio Tools provides

    Visual Studio Tools for Microsoft Dynamics GP provides three main capabilities foran integrating application:

    Customized WinFormsAny WinForms included in an integrating application can use capabilities provided

    by Visual Studio Tools for Microsoft Dynamics GP to match the appearance of thecore application. The appearance of the window as well as the various controls in

    the window can be customized. You will learn about creating windows for yourintegration in Chapter 4, WinForms,and Chapter 5, Control Reference.

    Access to dictionary resourcesIntegrating applications have access to the numerous resources available in theapplication dictionaries used for Microsoft Dynamics GP. An integratingapplication can access the forms, windows, window fields, tables, and table fields ineach dictionary. They can also access global variables, commands, procedures, andfunctions defined in each dictionary. You will learn about accessing dictionaryresources in Chapter 7, Accessing Dictionary Resources.

    Access to events

    Integrating applications can be notified of events that occur in Microsoft DynamicsGP, such as a window being opened, or the focus moving to a field. The applicationscan respond to the events, performing actions like verifying field values or openingadditional windows. Chapter 8, Events, contains information about registeringfor and responding to events.

    Architecture

    Visual Studio Tools for Microsoft Dynamics GP consists of runtime components anddevelopment components.

    Runtime componentsThe runtime components for Visual Studio Tools are installed with Microsoft

    Dynamics GP, and provide the functionality used by the integrations. These consistof the following:

    Dexterity Shell This assembly (Microsoft.Dexterity.Shell.dll) provides thedrawing capabilities that allow an integrating application to match the appearanceof Microsoft Dynamics GP.

    Dexterity Bridge This assembly (Microsoft.Dexterity.Bridge.dll) provides theaccess to events in Microsoft Dynamics GP, as well as the resources in theapplication dictionaries.

  • 8/6/2019 Microsoft GP 10(VSTDGPProgrammersGuide)

    18/120

    P A R T 1 G E T T I N G S T A R T E D

    12 P R O G R A M M E R S G U I D E

    Application assemblies Each dictionary that will be accessed by a VisualStudio Tools for Microsoft Dynamics GP integration will have an applicationassembly. Each application assembly provides access to the resources in itscorresponding dictionary. For example, the Application.Dynamics.dll assemblyprovides access to the resources in the Dynamics.dic dictionary.

    Visual Studio Tools for Microsoft Dynamics GP includes the application assemblies

    for all the modules that ship with Microsoft Dynamics GP. You can use theDictionary Assembly Generator tool (Dag.exe) to create application assemblies forother third-party dictionaries for Microsoft Dynamics GP. You will learn more aboutthis tool in Chapter 6, Dictionary Assembly Generator.

    AddIns folder The assemblies for the integrating applications created withVisual Studio Tools for Microsoft Dynamics GP are placed in this folder. WhenMicrosoft Dynamics GP is launched, it automatically looks in this folder andattempts to launch the integrating applications it finds there.

    Development componentsThe following development components are installed in the folder where you choseto install Visual Studio Tools for Microsoft Dynamics GP:

    DAG.exe This is the Dictionary Assembly Generator tool, used to createapplication assemblies for dictionaries. You will use this to create applicationassemblies for third-party dictionaries that do not have them. You will also use it tocreate application assemblies for forms dictionaries in cases where your integrationmust interact with modified forms in Microsoft Dynamics GP.

    IntelliSense XML files The IntelliSense XML file contains the informationabout the application assembly that is displayed in the IntelliSense within VisualStudio. The name of the application XML file matches that of the applicationassembly it corresponds to. For example, the Application.Dynamics.xml filecontains information about the Application.Dynamics.dll assembly.

    The following components are installed into the Visual Studio installation:

    Visual Basic project This is the template project for an add-in that is based inVisual Basic.

    Visual C# project This is the template project for an add-in that is based inVisual C#.

    Creating a project

    Use the following procedure to create a new Visual Studio project for a MicrosoftDynamics GP add-in.

    1. Start Visual Studio.

    If it isnt already running, start Visual Studio.

    2. Create a new project.

    In the File menu, point to New and choose Project.

    3. Select the project type.

    Choose either a Visual Basic project or a Visual C# project. Under the type youhave selected, choose Dynamics GP.

  • 8/6/2019 Microsoft GP 10(VSTDGPProgrammersGuide)

    19/120

    P R O G R A M M E R S G U I D E 13

    C H A P T E R 2 I N T E G R A T I O N B A S I C S

    4. Choose the Microsoft Dynamics GP Add-in template.

    In the list of available templates, choose the Microsoft Dynamics GP Add-inproject template.

    If the Microsoft Dynamics GP templates are not listed, you may need to register themmanually. Refer to Template registration on page 8 for details about doing this.

    5. Specify the name and location of the project.

    Click OK to create the project.

  • 8/6/2019 Microsoft GP 10(VSTDGPProgrammersGuide)

    20/120

    14 P R O G R A M M E R S G U I D E

  • 8/6/2019 Microsoft GP 10(VSTDGPProgrammersGuide)

    21/120

    P R O G R A M M E R S G U I D E 15

    Chapter 3: Upgrading an Integration

    If you have created an integration with Visual Studio Tools for Microsoft DynamicsGP 9, use the following procedures to upgrade your integration to work with thecurrent version of Visual Studio Tools. Be sure you have installed the currenversion of Visual Studio Tools before attempting to upgrade your integrations. Thefollowing upgrade procedures are described:

    C# integration Visual Basic integration

    C# integration

    Use the following procedure to upgrade a Visual Studio Tools integration createdwith C#.

    1. Open the solution for your integration.

    Using Visual Studio, open the solution file for the integration you want toupgrade.

    2. Rebuild application assemblies.

    If you had built any application assemblies for your integration, you will needto re-build them so they are up-to-date with the latest version of MicrosoftDynamics GP.

    3. Update the assembly references.

    The assembly references for the project will be incorrect, because they wonrefer to the new versions of the Visual Studio Tools components and applicationassemblies.

    Add references to the updated Visual Studio Tools assemblies, to replace the

    broken references.

    The reference to the Microsoft.Dexterity.Shell.UI assembly is a special situation. Thiscomponent was merged into the Microsoft.Dexterity.Shell assembly. Create a referencto the Microsoft.Dexterity.Shell assembly, and delete the reference to the

    Microsoft.Dexterity.Shell.UI assembly.

    The assembly references

    are incorrect and need to

    be updated.

  • 8/6/2019 Microsoft GP 10(VSTDGPProgrammersGuide)

    22/120

    P A R T 1 G E T T I N G S T A R T E D

    16 P R O G R A M M E R S G U I D E

    4. Update the namespaces used in integration code.

    The namespace for the shell (user interface) components of the Visual StudioTools integration has changed. The namespace reference must be changed from:

    Microsoft.Dexterity.Shell.UI

    To the updated value:

    Microsoft.Dexterity.Shell

    5. Update the namespace references used for any forms.

    The same namespace change must be made for any forms you created for yourintegration. When you attempt to open a form in the Visual Studio designer,you will see an error similar to the following:

    This means that the code used for the form is using the old namespace, ratherthan the new Microsoft.Dexterity.Shell namespace. You must view the code forthe form, and change all of the namespace references to remove the UIportion. This will be required in several places. An example of code to be fixedis shown highlighted in the following illustration.

    You may need to expand some hidden sections of the code to find all of the references.

    After making these changes to the forms code, save the updated file. Close theform designer if it is still open, and then re-open the form. The form should nowopen and have the updated Microsoft Dynamics GP appearance.

    6. Build the solution.

    Choose to build the updated solution in Visual Studio. You may encounterbuild errors if your integration references resources in Microsoft Dynamics GPthat have been deleted, moved, or renamed. You will need to fix these issuesand rebuild the integration.

  • 8/6/2019 Microsoft GP 10(VSTDGPProgrammersGuide)

    23/120

    P R O G R A M M E R S G U I D E 17

    C H A P T E R 3 U P G R A D I N G A N I N T E G R A T I O N

    Visual Basic integration

    Use the following procedure to upgrade a Visual Studio Tools integration createdwith Visual Basic.

    1. Open the solution for your integration.

    Using Visual Studio, open the solution file for the integration you want to

    upgrade.

    2. Rebuild application assemblies.

    If you had built any application assemblies for your integration, you will needto re-build them so they are up-to-date with the latest version of MicrosoftDynamics GP.

    3. Update the assembly references.

    The assembly references for the project will be incorrect, because they wonrefer to the new versions of the Visual Studio Tools components and applicationassemblies.

    Add references to the updated Visual Studio Tools assemblies, to replace thebroken references.

    The reference to the Microsoft.Dexterity.Shell.UI assembly is a special situation. Thiscomponent was merged into the Microsoft.Dexterity.Shell assembly. Create a referencto the Microsoft.Dexterity.Shell assembly, and delete the reference to the

    Microsoft.Dexterity.Shell.UI assembly.

    4. Update the namespaces used in integration code.

    The namespace for the shell (user interface) components of the Visual StudioTools integration has changed. Any namespace reference must be changedfrom:

    Microsoft.Dexterity.Shell.UI

    To the updated value:

    Microsoft.Dexterity.Shell

    The assembly references

    are incorrect and need to

    be updated.

  • 8/6/2019 Microsoft GP 10(VSTDGPProgrammersGuide)

    24/120

    P A R T 1 G E T T I N G S T A R T E D

    18 P R O G R A M M E R S G U I D E

    5. Update the namespace references used for any forms.

    The same namespace change must be made for any forms you created for yourintegration. When you attempt to open a form in the Visual Studio designer, thecode for the form will be displayed:

    6. Update the form designer code.

    Open the Designer source file for the form to fix the references so they use thenew Microsoft.Dexterity.Shell namespace. Change all of the namespacereferences to remove the UI portion. This will be required in several places.An example of code to be fixed is shown in the following illustration.

    After making these changes to the forms code, save the updated file. Re-openthe form. The form should appear in the form designer and have the updatedMicrosoft Dynamics GP appearance.

    7. Build the solution.

    Choose to build the updated solution in Visual Studio. You may encounterbuild errors if your integration references resources in Microsoft Dynamics GPthat have been deleted, moved, or renamed. You will need to fix these issuesand rebuild the integration.

    Fix the namespace

    references for the form.

    Fix all of the references

    to use the new

    Microsoft.Dexterity.Shell

    namespace.

  • 8/6/2019 Microsoft GP 10(VSTDGPProgrammersGuide)

    25/120

  • 8/6/2019 Microsoft GP 10(VSTDGPProgrammersGuide)

    26/120

    20 P R O G R A M M E R S G U I D E

    Part 2: Developing IntegrationsThis portion of the documentation describes the various techniques you will use asyou develop integrations using Visual Studio Tools for Microsoft Dynamics GP. Thefollowing topics are discussed:

    Chapter 4, WinForms, describes how to create WinForms that have theappearance of windows in Microsoft Dynamics GP.

    Chapter 5, Control Reference, provides details of the various controls that aremodified by Visual Studio Tools for Microsoft Dynamics GP.

    Chapter 6, Dictionary Assembly Generator, describes the tool used to create.NET assemblies that provide access to dictionary resources.

    Chapter 7, Accessing Dictionary Resources, explains how to access resourcesin dictionaries from your integrating application.

    Chapter 8, Events, describes how to register for and respond to events for

    Microsoft Dynamics GP.

    Chapter 9, Working with Tables, describes how to directly access MicrosoftDynamics GP tables from an integration.

    Chapter 10, Building and Deploying, explains how to build and deploy anintegration you have created.

    Chapter 11, Debugging, explains how to debug an integration created withVisual Studio Tools for Microsoft Dynamics GP.

    Chapter 12, Modified and Alternate Forms,describes how to access resourceson modified forms and alternate forms in Microsoft Dynamics GP.

  • 8/6/2019 Microsoft GP 10(VSTDGPProgrammersGuide)

    27/120

    P R O G R A M M E R S G U I D E 21

    Chapter 4: WinForms

    Standard WinForms are the basis for the user interface for add-ins created withVisual Studio Tools for Microsoft Dynamics GP. These WinForms and the controlsplaced on them are specially modified to match the appearance of MicrosoftDynamics GP. Information about WinForms is divided into the following sections:

    Adding a Dynamics GP form to a project WinForm properties Adding controls

    Adding a Dynamics GP form to a project

    To add a new Dynamics GP form to an add-in project, complete the followingprocedure:

    1. Add a new component.

    In Visual Studio, choose Add Component from the Project menu.

    2. Select a Microsoft Dynamics GP Form.In the list of templates, choose a Microsoft Dynamics GP form.

    3. Name the new form.

    Give the form a name that is appropriate for how it will be used.

    4. Add the new form.

    Click Add to add the new WinForm to the project.

    5. Specify the form properties.

    Set the necessary properties for the new form.

    Choose a Microsoft

    Dynamics GP Form.

  • 8/6/2019 Microsoft GP 10(VSTDGPProgrammersGuide)

    28/120

    P A R T 2 D E V E L O P I N G I N T E G R A T I O N S

    22 P R O G R A M M E R S G U I D E

    WinForm properties

    WinForms that are added to a Visual Studio Tools for Microsoft Dynamics GPproject have several additional properties that control their appearance. Settingthese properties correctly helps match the appearance of Microsoft Dynamics GP.These properties are:

    AutoSetDexColors ControlArea StatusArea

    These WinForm properties are found in the Dexterity group in the Properties pane inVisual Studio.

    AutoSetDexColorsThe AutoSetDexColors property controls whether the colors used for the WinFormwill automatically match the color scheme selected in the user preferences withinMicrosoft Dynamics GP. Set this property to True to match the Microsoft DynamicsGP appearance.

    ControlAreaThe ControlArea property specifies whether the band called the control area isdrawn at the top of the WinForm. In standard Microsoft Dynamics GP windows,controls such as Save, Clear, and Delete buttons are placed in the control area. Setthis property to True to display the control area for a WinForm.

    StatusAreaThe StatusArea property specifies whether the band called the status area is drawnat the bottom of the WinForm. A divider line is drawn across the bottom of theWinForm to indicate the status area. In standard Microsoft Dynamics GP windows,controls like browse buttons, note buttons, and help buttons are placed in the statusarea. Set this property to True to display the status area for a WinForm.

    This is the control area.

    This is the status area.

  • 8/6/2019 Microsoft GP 10(VSTDGPProgrammersGuide)

    29/120

    P R O G R A M M E R S G U I D E 23

    C H A P T E R 4 W I N F O R M S

    Adding controls

    You can add controls to the forms for your Microsoft Dynamics GP integration thesame way you add them to standard windows forms. Simply select the control inthe Toolbox and drag it out onto the form.

    When you add the controls, additional properties will be available for some of themto match the Microsoft Dynamics GP appearance. For example, push buttons willhave additional properties. Refer to Chapter 5, Control Reference, for moreinformation about individual controls.

    To add a control, just

    select it in the Toolbox

    and drag it onto the form.

  • 8/6/2019 Microsoft GP 10(VSTDGPProgrammersGuide)

    30/120

    24 P R O G R A M M E R S G U I D E

  • 8/6/2019 Microsoft GP 10(VSTDGPProgrammersGuide)

    31/120

    P R O G R A M M E R S G U I D E 25

    Chapter 5: Control Reference

    You can use any of the available controls on the WinForms for your MicrosoftDynamics GP integration. Some of the standard controls have been customized to

    better match the appearance of Microsoft Dynamics GP. This portion of thdocumentation describes the controls that have additional properties or updatedcharacteristics when used on a WinForm in a Visual Studio Tools for MicrosoftDynamics GP project. The following controls are discussed:

    Buttons TextBoxes Labels ComboBoxes ListBoxes

    Buttons

    Button controls are used for each of the button types in a Microsoft Dynamics GPform. The button controls on a WinForm for a Microsoft Dynamics GP project get

    their additional characteristics from the dexButtonProvider you see on theWinForm layout. The ButtonType property is an additional property available foreach button. It specifies how the button control is displayed and whatcharacteristics it will have. You can set the AutoSetDexColors property to True sothe button colors will match colors in Microsoft Dynamics GP.

    The following is a list of the settings for the ButtonType property, and a descriptionof how each button type is used.

    StandardStandard buttons dont have their appearance modified changed when placed on aWinForm for a Dynamics GP project. The following illustration shows a standard

    button.

    ToolbarButtons with the ButtonType set to Toolbar are typically placed in the control area ofa Microsoft Dynamics GP form. These buttons have a flat appearance, with a speciacolor highlighting when the pointer is placed over them. It is also common for these

    buttons to have pictures on them. The following illustration shows a toolbar button

    This is a standard button

    A toolbar button is

    typically placed in the

    control area.

  • 8/6/2019 Microsoft GP 10(VSTDGPProgrammersGuide)

    32/120

    P A R T 2 D E V E L O P I N G I N T E G R A T I O N S

    26 P R O G R A M M E R S G U I D E

    ToolbarWithSeparatorThe buttons with the type ToolbarWithSeparator buttons are typically placed in thecontrol area, like buttons with the type Toolbar. However, they have an additionalseparator line drawn on the right side of the button to separate it from the othercontrols in the control area. The following illustration shows two buttons that havethe type ToolbarWithSeparator. Notice the separator line drawn to the right of each

    button.

    StatusAreaButtons placed in the status area at the bottom of a window should have the typeStatusArea. These buttons should display only graphics, and will have a special 3-D

    border drawn around them when the pointer is placed over them. These buttonsshould have the Tooltip property set so they will display a description of the actionthe button performs. A status area button is shown in the following illustration. Itdisplays a tooltip that describes the purpose of the button.

    FieldButtons that show only pictures, and are placed next to other controls in the formshould have the ButtonType property set to Field. These buttons are used for thingslike lookups or expansions. Several buttons with this type are shown next to a textcontrol in the following illustration.

    Pictures for buttonsEach Visual Studio for Microsoft Dynamics GP project includes several standardimages that are used for buttons in Microsoft Dynamics GP. These images (in PNGformat) should be used with the buttons you create for your integrations. Thefollowing table lists the images and describes how they are used.

    These are toolbar buttons

    with separators.

    Buttons in the status area

    typically have only pictures.

    These are field

    buttons.

    Image Name Description

    Field_Delete.png Used for delete buttons in the window area placednext to fields.

    Field_Edit.png Used for edit buttons in the window area placed next

    to fields.

    Field_Expansion.png Used for expansion buttons in the window area

    placed next to fields.

    Field_Lookup.png Used for lookup buttons in the window area placed

    next to fields.

    Field_MapPoint.png Used for MapPoint buttons in the window area placed

    next to fields.

  • 8/6/2019 Microsoft GP 10(VSTDGPProgrammersGuide)

    33/120

    P R O G R A M M E R S G U I D E 27

    C H A P T E R 5 C O N T R O L R E F E R E N C E

    TextBoxesTextBox controls are used for the string, integer, currency, date, and time controls ina Microsoft Dynamics GP form. Text boxes have the AutoSetDexColors propertythat can be set to True so the control colors will match colors in Microsoft DynamicsGP.

    Field_NoteAbsent.png Used for note buttons in the window area placed next

    to fields.

    Field_NotePresent.png Used for note buttons in the window area placed next

    to fields.

    HelpImage.png Used for the Help button placed in the status area of

    the window.

    Toolbar_Cancel.png Used for the Cancel button placed in the window

    control area.

    Toolbar_Clear.png Used for the Clear button placed in the window

    control area.

    Toolbar_Copy.png Used for the Copy button placed in the window

    control area.

    Toolbar_Delete.png Used for the Delete button placed in the window

    control area.

    Toolbar_DeleteAll.png Used for the Delete All button placed in the window

    control area.

    Toolbar_New.png Used for the New button placed in the window control

    area.

    Toolbar_Open.png Used for the Open button placed in the window

    control area.

    Toolbar_Post.png Used for the Post button placed in the window control

    area.

    Toolbar_Print.png Used for the Print button placed in the window control

    area.

    Toolbar_Redisplay.png Used for the Redisplay button placed in the window

    control area.

    Toolbar_Save.png Used for the Save button placed in the window

    control area.

    Toolbar_Void.png Used for the Void button placed in the window control

    area.

    VCR_First.png Used for the First browse control in the window status

    area.VCR_Last.png Used for the Last browse control in the window status

    area.

    VCR_Next.png Used for the Next browse control in the window

    status area.

    VCR_Previous.png Used for the Previous browse control in the window

    status area.

    Window_NoteAbsent.png Used for the note button in the window status area.

    Window_NotePresent.png Used for the note button in the window status area.

    Image Name Description

    A TextBox control is used

    for standard fields like

    currency values.

  • 8/6/2019 Microsoft GP 10(VSTDGPProgrammersGuide)

    34/120

    P A R T 2 D E V E L O P I N G I N T E G R A T I O N S

    28 P R O G R A M M E R S G U I D E

    Unlike the standard controls in Microsoft Dynamics GP, the textbox controls haveno built-in support to format data such as currency values. You will need to addadditional code to your integration to match the behavior of the controls inMicrosoft Dynamics GP. For instance, the following C# code sets the value of thetextbox in the previous illustration. It uses the Format method for the String objectto format the currency value.

    // Display the value, formatting it as a currency amounttextBoxEstimatedFreight.Text = String.Format("{0:C}",EstimatedFreight);

    Labels

    Label controls are used for the text labels that appear next to controls in theMicrosoft Dynamics GP form. They correspond to the static text items that appearin standard Microsoft Dynamics GP windows.

    Label controls have the LinkField property that should be set when a specific fieldis being labeled. This property is set to the name of the control that the label appliesto. When specified in the Microsoft Dynamics GP User Preferences, the label will bedrawn with the single underline that is standard for prompts.

    To have the underlined label draw correctly, be sure theAutoSize property for the label is setto False.

    ComboBoxes

    Use the ComboBox control in cases where you would use a drop-down list or

    combo box in Microsoft Dynamics GP. ComboBox controls have theAutoSetDexColors property that can be set to True so the control colors will matchcolors in Microsoft Dynamics GP.

    The following illustration shows a ComboBox control being used as a drop-downlist in a Microsoft Dynamics GP form.

    ListBoxes

    Use the ListBox control in cases where you would used a list box or multi-select listbox in Microsoft Dynamics GP.

    A label control displays

    the text label that appears

    next to another control.

  • 8/6/2019 Microsoft GP 10(VSTDGPProgrammersGuide)

    35/120

    P R O G R A M M E R S G U I D E 29

    Chapter 6: Dictionary Assembly Generator

    The Dictionary Assembly Generator (DAG.exe) is a utility included with VisualStudio Tools for Microsoft Dynamics GP that creates a managed code assembly thatprovides access to resources in an application dictionary. Information about this toois divided into the following sections:

    Creating application assemblies Output files Using the Dictionary Assembly Generator Optimizing the assembly generating process

    Creating application assemblies

    Several application assemblies are included with the Visual Studio Tools forMicrosoft Dynamics GP. These are the assemblies for the core application(Dynamics.dic) and the other applications that are delivered with MicrosoftDynamics GP.

    When developing integrations that use resources from these dictionaries, alwaysuse the application assemblies that are included with the Visual Studio Toolsinstallation. These assemblies are digitally signed, indicating they were produced

    by Microsoft. Dont generate your own versions of application assemblies fodictionaries shipped with the Microsoft Dynamics GP product.

    You will create application assemblies for the following cases:

    A forms dictionary exists for a product, and you want your Microsoft DynamicsGP integration to access the modified resources in the forms dictionary.

    You have installed a third-party dictionary for which no application assemblyexists, and you want to access resources in this dictionary from your Microsoft

    Dynamics GP integration. The third-party dictionary could contain new formsand other resources. It could contain alternate forms from the Dynamics.dicdictionary.

    Output files

    The Dictionary Assembly Generator produces two output files that are used in yourintegration: an application assembly and IntelliSense data file.

    Application assemblyThe most important output is the application assembly. This is the managed codeassembly that provides access to the resources in a dictionary. Each dictionary can

    have one corresponding application assembly.

    The following naming convention is used for application dictionaries:

    Application.ProductName.dll

    The following naming convention is used for forms dictionaries:

    Application.ProductName.ModifiedForms.dll

  • 8/6/2019 Microsoft GP 10(VSTDGPProgrammersGuide)

    36/120

    P A R T 2 D E V E L O P I N G I N T E G R A T I O N S

    30 P R O G R A M M E R S G U I D E

    ProductName is automatically derived from product name in the launch file. Anyspaces or special characters in the product name are removed.

    For example, the application assembly that provides access to resources in theSRVCADV.dic application dictionary is named Application.FieldService.dll. Theapplication assembly that provides access to the resources in the forms dictionary(FRMS949..dic) is named Application.FieldService.ModifiedForms.dll.

    IntelliSense data fileThe second type of output from the Dictionary Assembly Generator is theIntelliSense data file that will be used by Visual Studio. This file has the same nameas its corresponding application assembly, but has the .xml extension. As you writecode, Visual Studio will use the information from this file to display details aboutthe resources that can be accessed through the application assembly. An example ofthe IntelliSense for a dictionary resource is shown in the following illustration.

    Using the Dictionary Assembly Generator

    The Dictionary Assembly Generator (DAG.exe) is installed in the location whereyou installed Visual Studio Tools. Typically this will be the following location:

    C:\Program Files\Microsoft Dynamics\GP10 VS Tools SDK

    The Dictionary Assembly Generator is a command-line tool, and should be runfrom a command prompt. Open a command prompt and set the current location to

    the folder where DAG.exe is located.

    To view the command syntax, use the following command at the command prompt:

    dag.exe /?

    The Dictionary Assembly Generator uses the product ID to identify the dictionaryfor which you want to build the application assembly. Look in the launch file(typically Dynamics.set) for a list of the products installed.

    Information from the

    application assembly

    XML file is displayed in

    IntelliSense.

  • 8/6/2019 Microsoft GP 10(VSTDGPProgrammersGuide)

    37/120

    P R O G R A M M E R S G U I D E 31

    C H A P T E R 6 D I C T I O N A R Y A S S E M B L Y G E N E R A T O R

    Optionally, you can specify the launch file that the Dictionary Assembly Generatorwill look in to find the list of installed products and the corresponding dictionarylocations. If you dont supply the name of the launch file, DAG.exe will look for thelaunch file named Dynamics.set in the current location.

    Since you are running DAG.exe from a different location than where Microsoft DynamicsGP is installed, you will need to supply the complete path to the launch file.

    The Dictionary Assembly Generator must be able to write to the location where it is beingrun from. Typically, this means the user running DAG.exe must be part of the

    Administrators group or the Power Users group on Windows XP. On Windows Vista, imeans launching DAG.exe with Administrative privileges.

    Building an application assemblyThe Dictionary Assembly Generator will build an application assembly for the maindictionary for an application or for the forms dictionary for an application. Whengenerating an assembly for an application dictionary, use the /M parameter. Forexample, the following command generates the application assembly for the maindictionary of the Sample Integrating Application. This application has the producID value 3333. The path to the launch file (Dynamics.set) is supplied.

    dag.exe 3333 "C:\Program Files\Microsoft Dynamics\GP\Dynamics.set" /M

    This command produces two files:

    Application.SampleIntegratingApp.dll Application.SampleIntegratingApp.xml

    To generate an assembly for a forms dictionary, use the /F parameter. For examplethe following command generates the application assembly for the forms dictionaryof the Field Service product (with dictionary ID 949).

    dag.exe 949 "C:\Program Files\Microsoft Dynamics\GP\Dynamics.set" /F

    This command produces two files:

    Application.FieldService.ModifiedForms.dll Application.FieldService.ModifiedForms.xml

    Refer toModified forms on page 65for details about creating an application assembly for theforms dictionary (Forms.dic) used by Microsoft Dynamics GP.

    Signing an application assemblyYou may want to sign the application assemblies you create. This is a good practice

    because it helps ensure that only the official version of an application assembly is being used. The Dictionary Assembly Generator can sign the assemblies that icreates. It can fully sign the assemblies, or delay sign them. You can use the SN.exe

    utility (included with the .NET Framework) to create a strong name key file (.snk)used to sign the assembly.

    Once you create and use a strong name key file, keep it in a safe location. You will need to useit every time you build or rebuild application assemblies.

    The following example shows how the application assembly for the sampleintegrating application is fully signed using the Sample.snk strong name key. TheSample.snk file was generated using the SN.exe utility.

    dag.exe 3333 "C:\Program Files\Microsoft Dynamics\GP\Dynamics.set" /M

    /S:Sample.snk

  • 8/6/2019 Microsoft GP 10(VSTDGPProgrammersGuide)

    38/120

    P A R T 2 D E V E L O P I N G I N T E G R A T I O N S

    32 P R O G R A M M E R S G U I D E

    Overriding the application assembly nameWhen creating an application assembly for a dictionary, the Dictionary AssemblyGenerator will use the product name from the launch file. This may not be the nameyou want to use for the application assembly. You can use the /N parameter tospecify a different name for the application assembly being generated.

    For example, the following command will create an application assembly for the

    sample integrating application, but use the name Develop instead of the productname in the launch file.

    dag.exe 3333 "C:\Program Files\Microsoft Dynamics\GP\Dynamics.set" /M

    /N:Develop

    The generated application assembly will have the name Application.Develop.dll.

    Overriding the main referenced dictionary nameWhen generating application assemblies for dictionaries that integrate withMicrosoft Dynamics GP, the Dictionary Assembly Generator must be able toreference the application assembly for the main dictionary (typicallyApplication.Dynamics.dll). If the application assembly for the main dictionary has

    been given a different name, you can use the /NM parameter to specify which newname so the application assembly can be found.

    For example, if the application assembly for the main dictionary was namedApplication.DynamicsGP.dll, you would use the following command to create anapplication assembly for the sample integrating application. Notice that the /NMparameter is used to specify the name of the main application assembly that is beingreferenced.

    dag.exe 3333 "C:\Program Files\Microsoft Dynamics\GP\Dynamics.set" /M

    /NM:DynamicsGP

    Optimizing the assembly generating processProducing an application assembly for large dictionaries is a resource-intensiveprocess. The Dictionary Assembly Generator will use a large amount of memory(often over 1 gigabyte) and substantial processor time when producing anapplication assembly. To optimize the process, do the following:

    Use the best hardware you have available to generate the application assembly.

    Close all other applications before starting the process.

    Temporarily turn off background processing tasks, such as virus scanning.

  • 8/6/2019 Microsoft GP 10(VSTDGPProgrammersGuide)

    39/120

    P R O G R A M M E R S G U I D E 33

    Chapter 7: Accessing Dictionary Resources

    To create an integration for Microsoft Dynamics GP or the additional applicationsthat are installed with it, your code must access resources in the various applicationdictionaries. This portion of the documentation describes how to do this for yourproject. The following topics are discussed:

    Adding references Namespace Dictionary class Accessing additional resources Variables for dictionary resources

    Adding references

    To access the resources in a specific dictionary, a project must contain a reference tothe application assembly for that dictionary. When you create a new Visual StudioTools for Microsoft Dynamics GP project, it will automatically contain a reference tothe Application.Dynamics.dll application assembly. This provides access to

    resources in the Dynamics.dic dictionary. To access resources in other dictionariesadd references to the application assemblies for them.

    If a dictionary doesnt have a corresponding application assembly, refer to Chapter 6Dictionary Assembly Generator, to learn how to create one.

    For example, to access resources from the Sample Integrating App applicationinstalled with Microsoft Dynamics GP, the project should contain a reference to theApplication.SampleIntegratingApp.dll application assembly. The followingillustration shows this reference for a C# project.

    This reference provides

    access to the resources in

    the corresponding

    dictionary.

  • 8/6/2019 Microsoft GP 10(VSTDGPProgrammersGuide)

    40/120

    P A R T 2 D E V E L O P I N G I N T E G R A T I O N S

    34 P R O G R A M M E R S G U I D E

    Namespace

    Resources for a dictionary are accessed through the following namespace:

    Microsoft.Dexterity.Applications

    To make it convenient to access resources, this namespace is included in the C#project template with the using statement. In the Visual Basic project template, itsincluded using the Imports statement. Referencing the namespace prevents youfrom having to fully-qualify references to dictionary resources.

    Dictionary class

    The resources in a dictionary are accessed through a single class that is availableafter you add the reference to the dictionarys application assembly. The class hasthe same name that appears in the application assembly. For instance, the class toaccess resources for the Dynamics dictionary is named Dynamics. Similarly, theclass used to access resources for the Sample Integrating Application is namedSampleIntegratingApp. This is the same name that appears in the applicationassembly, Application.SampleIntegratingApp.dll.

    The five primary resource types in a dictionary are accessed through properties ofthe class. These resource types are:

    Forms Globals Procedures Functions Tables

    To access a resource of the specific type, start by typing the dictionary class name,and then property for the resource type. IntelliSense in Visual Studio will present alist of the specific type of resources available in the dictionary. For example, the

    following illustration shows the forms resources in the Dynamics core application.

    When youve selected a resource of the specific type, you will see a list of theproperties, methods, and events available for that resource. The following

    illustration shows some of the properties, methods, and events for the AboutBoxform in the Dynamics dictionary.

    Type the dictionary class name

    and the resource type

    property. IntelliSense displays

    a list of resources.

  • 8/6/2019 Microsoft GP 10(VSTDGPProgrammersGuide)

    41/120

    P R O G R A M M E R S G U I D E 35

    C H A P T E R 7 A C C E S S I N G D I C T I O N A R Y R E S O U R C E S

    Accessing additional resources

    Several additional resource types are accessed through the Forms property of adictionary class. These include:

    Windows Commands

    Form-level procedures Form-level functions Form-level table buffers

    As an example, the following C# statement opens the Customer Maintenancewindow. Notice how the window is accessed through the form object.

    Dynamics.Forms.RmCustomerMaintenance.RmCustomerMaintenance.Open();

    Windows provide further access to two additional resource types:

    Fields Scrolling windows

    For instance, the following C# statement sets the value of the Comment 1 field in theVendor Maintenance window.

    Dynamics.Forms.PmVendorMaintenance.PmVendorMaintenance.Comment1.Value

    = "A preferred vendor";

    You will learn more about the details about using each resource type in Part 3, ResourceReference.

    Variables for dictionary resources

    Within your code, it may be useful to create variables for specific resources in anapplication dictionary. The definitions for the various dictionary resources arefound in an additional namespace available in the application assembly. Thisnamespace has the same name that appears in the application assembly, but hasDictionary appended. For instance, to reference the definitions for resources inthe Dynamics main dictionary, you would use this namespace:

    Microsoft.Dexterity.Applications.DynamicsDictionary

    To reference resources for the Sample Integrating Application, you would use thisnamespace:

    Microsoft.Dexterity.Applications.SampleIntegratingAppDictionary;

    After creating the variable, you can assign its value and then use it in your code. Forexample, the following C# code creates a variable for the Vendor Maintenance formin Microsoft Dynamics GP. It assigns the form to the variable, and then uses it toopen the form.

    PmVendorMaintenanceForm VendorMaintenanceForm;

    VendorMaintenanceForm = Dynamics.Forms.PmVendorMaintenance;

    VendorMaintenanceForm.Open();

  • 8/6/2019 Microsoft GP 10(VSTDGPProgrammersGuide)

    42/120

    P A R T 2 D E V E L O P I N G I N T E G R A T I O N S

    36 P R O G R A M M E R S G U I D E

    Using a variable can simplify your code, especially when accessing dictionaryresources that have long names. For example, the following C# code creates avariable for the Customer Maintenance window in Microsoft Dynamics GP. Then itsets the values of two fields in the window. Notice it take less code to set the fieldwhen the variable for the window is used.

    // Create the variable and set its value

    RmCustomerMaintenanceForm.RmCustomerMaintenanceWindow CustMaintWindow;CustMaintWindow = Dynamics.Forms.RmCustomerMaintenance.RmCustomerMaintenance;

    // Accessing window fields requires less code when using the variable

    CustMaintWindow.Comment1.Value = "Comment 1";

    Dynamics.Forms.RmCustomerMaintenance.RmCustomerMaintenance.Comment2.Value =

    "Comment 2";

  • 8/6/2019 Microsoft GP 10(VSTDGPProgrammersGuide)

    43/120

    P R O G R A M M E R S G U I D E 37

    Chapter 8: Events

    Applications that integrate with Microsoft Dynamics GP often need to be notifiedwhen specific events occur in the system. This portion of the documentationdescribes how to register to be notified when events occur in the system. It alsodescribes how to write event handlers that can respond to the events. Information isdivided into the following sections:

    Registering events Responding to events

    Registering events

    Your integrating application must register every event that it should be notified ofin the system. Event registrations are added to the Initialize() method, located inthe template code that is automatically added when you created your Visual StudioTools for Microsoft Dynamics GP project.

    The resources for which you can register events, such as forms, windows, or fields

    each list the events they make available. For example, a form has the followingevents available:

    OpenBeforeOriginal OpenAfterOriginal CloseBeforeOriginal CloseAfterOriginal

    Refer to each resource type described in Part 3, Resource Reference, for the list ofevents that are available for that resource.

    To register an event, find the resource for which you want to register the event. Pickthe event you want, and then specify the event handler method. The event handler

    is the method that contains the code that runs in response to the event.

    C#Visual Studio will assist you when you register an event in C# code. Begin byreferencing the resource for which you want to register an event. Add the +=operator, and Visual Studio will display IntelliSense indicating it will complete theevent handler. Simply press the TAB key to add the event handler registration.

  • 8/6/2019 Microsoft GP 10(VSTDGPProgrammersGuide)

    44/120

  • 8/6/2019 Microsoft GP 10(VSTDGPProgrammersGuide)

    45/120

    P R O G R A M M E R S G U I D E 39

    C H A P T E R 8 E V E N T S

    Responding to events

    The event handler method contains the code that runs in response to the event. Thiscode can perform whatever action is required for your integrating application. Forexample, the following C# code is the event handler that runs in response to thevalue of the Sales Document Number field being changed in the Sales TransactionEntry window. If the EstimateFreight form is open, the controls on the form are set.

    void SopNumber_Change(object sender, EventArgs e)

    {

    // If the Estimate Freight form is open, update the document number

    // and clear the other controls so the new calculation can be performed.

    if (EstimateFreightForm.Created == true)

    {

    EstimateFreightForm.textBoxDocumentNumber.Text =

    SOPEntryWindow.SopNumber.Value;

    EstimateFreightForm.textBoxEstimatedFreight.Clear();

    EstimateFreightForm.textBoxTotalWeight.Clear();

    }

    }

    Some events can be cancelled through the event handler. Typically, these are eventsthat occur before the event in the core application, such as the OpenBeforeOriginaevent for a form. The event argument parameter that is passed to the event handlerfor these events has a special type that allows the event to be cancelled.

    For example, the following Visual Basic example is the event handler for theBeforeOpen event of the Customer Maintenance form. The event handler methodexamines the current user logged into the system. If its the sa user, a message isdisplayed and the window isnt opened. Notice how the event arguments are usedto cancel the event.

    Public Sub RMCustMaintBeforeOpen(ByVal sender As Object, ByVal e _

    As System.ComponentModel.CancelEventArgs)

    If Dynamics.Globals.UserId.Value = "sa" Then

    'Display the message

    MsgBox("Do not access this window as the Administrator")

    'Prevent the form from opening

    Dynamics.Forms.RmCustomerMaintenance.Close()

    'Cancel pending events

    e.Cancel = True

    End If

    End Sub

  • 8/6/2019 Microsoft GP 10(VSTDGPProgrammersGuide)

    46/120

    40 P R O G R A M M E R S G U I D E

  • 8/6/2019 Microsoft GP 10(VSTDGPProgrammersGuide)

    47/120

    P R O G R A M M E R S G U I D E 41

    Chapter 9: Working with Tables

    A Visual Studio Tools integration can interact directly with tables defined inMicrosoft Dynamics GP. Using the table integration capability is much simpler thancreating and managing external connections to the Microsoft Dynamics GPdatabase. Information about working with tables is divided into the followingsections:

    Tables in Microsoft Dynamics GP Table buffers Opening and closing tables Keys Retrieving a row Saving a row Updating a row Removing a row Table operation errors Ranges Row locking

    Multiuser processing

    Tables in Microsoft Dynamics GP

    To learn about tables in Microsoft Dynamics GP, you will need to access informationfrom the following sources.

    Resource Descriptions toolThe Resource Descriptions tool available in Microsoft Dynamics GP providesessential details about each table in the application. Information such as the fields inthe table and the keys defined for the table can be found here.

    Important details, such as the

    keys defined for the table,

    can be found in the Table

    Descriptions window.

  • 8/6/2019 Microsoft GP 10(VSTDGPProgrammersGuide)

    48/120

    P A R T 2 D E V E L O P I N G I N T E G R A T I O N S

    42 P R O G R A M M E R S G U I D E

    Microsoft Dynamics GP SDKThe Microsoft Dynamics GP SDK contains detailed diagrams and descriptions ofthe tables in Microsoft Dynamics GP. You can use these diagrams to learn about thetable in a specific module, and how the tables work together. Information abouthow transactions flow through the various tables is also available in the MicrosoftDynamics GP SDK.

    IntelliSenseThe IntelliSense available in Visual Studio will be helpful by listing what tables areavailable, as well as which fields are available in those tables.

    Table buffersA table buffer provides access to one row of a specific table. The information in thetable buffer comes from either the table or a script that has run. Your code willinteract with the table buffer when you perform operations on the table. There aretwo types of table buffers: global and form-level.

    Aglobal table buffer is created when a table is accessed directly through the global listof tables. Global table buffers are accessed through the dictionary class. This classhas a Tables property that provides access to the collection of tables defined in thedictionary. A global table buffer is not shared with any other code. This makesglobal table buffers useful in situations where a Visual Studio Tools integrationmust read from or write to a Dynamics GP table, but isnt interacting with the user

    interface.

    A form-level table buffer is created when a table is attached to a form in MicrosoftDynamics GP. There is one table buffer for each table that is attached to the form.Each form-level table buffer is shared by the code that is part of the form, as well asany code outside of the form that accesses the table through that form. The Tablesproperty for the form allows access to the table buffers for the tables that areattached to the form. Because they are shared, form-level table buffers arenttypically used by Visual Studio Tools integrations to directly read from or write totables. Instead, the form-level table buffers are examined to find what data theDynamics GP window has read or is writing to the specific table.

    IntelliSense lists which

    tables are available. A

    description of each table

    is also provided.

    Global Visual Studio Tools

    Application CodeDynamics GP

    Table Table Buffer

  • 8/6/2019 Microsoft GP 10(VSTDGPProgrammersGuide)

    49/120

  • 8/6/2019 Microsoft GP 10(VSTDGPProgrammersGuide)

    50/120

    P A R T 2 D E V E L O P I N G I N T E G R A T I O N S

    44 P R O G R A M M E R S G U I D E

    Keys

    A key is a field or combination of fields in a table that is used to sort and locatespecific rows in the table. Typically, the value of the key field or fields is unique foreach row in a table so a specific row can be located. Keys that dont uniquelyidentify a specific row are used to refer to a range of rows in the table.

    The keys for a table are identified by number, beginning with the value 1. When youspecify the key you want to use for a table, you will supply the correspondinginteger. The Table Descriptions window in Microsoft Dynamics GP lists the keys foreach table, and the key segments (fields) that each key contains.

    You will use the keys for a table when you retrieve a specific row from the table.This is described in the next section, Retrieving a row. You will also use keys whenyou want to perform operations on a range of rows in the table. You will learn moreabout this in Ranges on page 49.

    Retrieving a row

    Retrieving a row from a table is a multi-step process. First, you must decide whichkey you want to use to retrieve the row. Use the Table Descriptions window inMicrosoft Dynamics GP to view the keys and each keys compon