Quantcast
Channel: Dynamics GP Help » VBA
Viewing all articles
Browse latest Browse all 5

Migrating VBA Customizations to VS Tools for Dynamics GP

$
0
0

With GP 2013 web client around the corner, there is lot of buzz around what’s going to be supported with web client and what’s not.

One of the things that not going to be supported in web client is VBA customizations. Therefore, its a good time to start upgrading your VBA customizations.

1. Planning:

In vba, code is saved in *.vba files in GP folder. For each dictionary file there is a corresponding vba file. You have to write your code in those existing files. You can’t divide these code files based on projects.

In VS Tools you can create projects for logically related customizations. This will help you in maintaining code in longer run and also isolating the issues related to different customizations. Therefore, if you are upgrading your vba customizations from vba to VS Tools, it’s a good time plan them carefully.

2. Select language- C#.net vs VB.net

VS Tools supports both C# and VB.net languages. You can select languages based on your personal preference and past experience. However, both languages are powerful developer tools and first-class programming languages that share the common language runtime in the .NET Framework. Here are some article which outlined difference between two languages

http://www.codeproject.com/Articles/9978/Complete-Comparison-for-VB-NET-and-C

http://support.microsoft.com/kb/308470

If you have lot of code which you want to convert as it to VS tools you can consider using VB.net because in terms of syntax VB.net is closer to vba and you will need fewer changes in the code.

3. Cross dictionary:

If your vba include cross dictionary references, you will need to add reference to assemblies for other dictionaries in your VS Tools solution. You can add reference using Project>> Add Reference menu option, browse to the dll you want to use. You can find dlls for core products in VS Tools installation folder.

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

Or

C:\ Program Files (x86)\Microsoft Dynamics\GP2010 VS Tools SDK\

 

Unlike vba, you don’t need to worry about circular reference in VS Tools environment.

4. For modified form and third party dictionaries, use DAG to generate assemblies

If your customization is based on modified forms or third party products. You can use  Dictionary Assembly Generator (DAG.exe) to create managed code assembly that provides access to resources in an dictionary.

The DAG.exe is installed in the location where you installed Visual Studio Tools SDK. Typically this will be the following location:

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

Or

C:\ Program Files (x86)\Microsoft Dynamics\GP2010 VS Tools SDK

Here is an examples of using DAG to generate dll for modified forms dictionary:

http://dynamicsgpblogster.blogspot.com.au/2009/10/vst-amount-in-words-on-sop-entry-window.html

DAG is command line utility, you can find Graphical User Interface (GUI) in following blog post:

http://blogs.msdn.com/b/developingfordynamicsgp/archive/2012/05/30/microsoft-dynamics-gp-addins-dag-utility.aspx

5. Access the Microsoft Dynamics Global Variables

Each dictionary has global variables related to it. Globals for an application dictionary are accessed through the dictionary class. This class has a Globals property that provides access to the collection of globals in the dictionary.

For example, to access the collection of globals in the Dynamics dictionary, use the following syntax:

Microsoft.Dexterity.Applications.Dynamics.Globals

To access a specific global value, such as the current user’s ID (UserId), use the following syntax:

Microsoft.Dexterity.Applications.Dynamics.Globals.UserId

6. Debugging the VS Tools code:

Debugging code in vba was very simple, you just add a break and perform action to hit the break point. However, in VS Tools the process you need to carry out the for debugging the code is:

  1. Build and deploy the integration in GP addins folder
  2. Set breakpoints in your code.
  3. Start Microsoft Dynamics GP
  4. Choose to attach to a process using menu option Select Debug >>Attach to Process from the menu in Visual studio
  5. Select the Dynamics.exe process
  6. Perform the actions you want to debug in Dynamics GP to hit the break points

Debugger in Visual Studio is very powerful tool. Refer to following article for using debugging in visual studio:

http://www.dotnetperls.com/debugging

http://msdn.microsoft.com/en-us/library/k0k771bt(v=vs.71).aspx

http://msdn.microsoft.com/en-us/library/01xdt7cs.aspx

7. DUOS objects:

Dynamic User Object Store (DUOS) is usually used for storing data from additional fields added using modifier. In VS Tools you can use table SyUserObjectStoreTable to save and access DUOS data

8. ADO Connections

If you are using ADO in your vba customization, you can use the GPConnNet.dll so that you don’t have to hard code a connection string. You can find this file in folder

C:\Program Files\Common Files\Microsoft Shared\Dexterity\v2.0

However, you will need to get keys from Microsoft support to use it. Refer to following article for details about how to use it to connect database

http://mbsguru.blogspot.com.au/2009/09/visual-studio-tools-integration-with-gp.html

9. San Script Alternative:

If you are using San Script in your vba code, consider using continuum. Continuum is the COM programming interface available for Microsoft Dynamics GP which has ability to run sanScript code in the Microsoft Dynamics GP application.

You can download documentation from Microsoft Dynamics GP 2010 Tools Documentation: Continuum Application Programmer’s Interface (API)

http://www.microsoft.com/en-au/download/details.aspx?id=17499

Here is an example of using Continuum

http://mohdaoud.blogspot.com.au/2009/10/practical-example-on-dynamics-continuum_7208.html

Note: The use of the Continuum Integration Library to execute Dexterity scripts from VBA is not supported.

10. Additional features available in VS Tools
a. Additional menu option in existing form:

You can additional menu option in Dynamics GP Forms through VS Tools. Here is an example to add menu option DynamicsGPAddin1 in Customer maintenance form

Microsoft.Dexterity.Applications.DynamicsDictionary.RmCustomerMaintenanceForm.AddMenuHandler(menu1, “DynamicsGPAddin1″);

b. Adding main menu using VS Tools

You can use “Menus for Visual Studio Tools” for Microsoft Dynamics GP 2010 to an menu option. You can download the dll for from partner source or customer source. Example you can a new menu option under Cards>> Sales using it.

Menus for Visual Studio Tools for Microsoft Dynamics GP 2010 (CustomerSource)
Menus for Visual Studio Tools for Microsoft Dynamics GP 2010 (PartnerSource)

c. Function and Procedure Notifications

VS Tools has option for Function and Procedure Notifications, you get before and after Notifications for the procedure and function call. It can be very handy to execute code globally based on procedure execution. Refer to following post for example:

http://blogs.msdn.com/b/developingfordynamicsgp/archive/2010/02/12/what-s-new-in-visual-studio-tools-2010.aspx

11. Not supported
a. Report Writer reports with VBA

If you have some existing vba code with report writer reports, you can consider using dexterity for such customizations.. VS tools does not have event handler for the report writer events.

b. Forms designed in VBA

You can design forms in VS tools and use them in customizations to replace the forms designed in VBA. However, they are not going to be supported in web client. Only forms designed in dexterity or modified using modifier will be available in web client. If your vba customization has custom forms you should consider using Dexterity to upgrade this customization for web client instead of VS Tools

Resources:

Other resources to help you get started with VS tools are:

Getting started with VS Tools:

http://dynamicsgpblogster.blogspot.com.au/2009/07/getting-started-with-vst-winforms-and.html

http://dynamicsgpblogster.blogspot.com.au/2009/08/getting-started-with-vst-winforms-and.html

Adding config file in VS Tools customization

http://blogs.msdn.com/b/developingfordynamicsgp/archive/2009/03/26/how-to-read-your-own-config-file-with-a-vstools-application.aspx


Viewing all articles
Browse latest Browse all 5

Latest Images

Trending Articles





Latest Images