Site Search:
Sign in | Join | Help

Creating a VSTools Projecct

Last post 06-10-2009 10:00 AM by Steve Gray. 0 replies.
Page 1 of 1 (1 items)
Sort Posts: Previous Next
  • 06-10-2009 10:00 AM

    • Steve Gray
    • Top 10 Contributor
      Male
    • Joined on 01-10-2007
    • Bradenton, Florida
    • Guru
    • Points 2,315

    Creating a VSTools Projecct

    Here's a quick walkthrough on creating your first VSTools project.

    Open Visual Studio (the screen shots here are from VS 2008)

    Choose FILE > NEW > PROJECT

    You should see something like the below. If not, you haven't installed VS Tools correctly. Go back to the install documentation.

     

    When it opens, you'll have a project with one class, GpAddin.vb. The code will look like this:

    Imports Microsoft.VisualBasic
    Imports System
    Imports System.Collections
    Imports System.Collections.Generic
    Imports Microsoft.Dexterity.Bridge
    Imports Microsoft.Dexterity.Applications
    
    
    Public Class GPAddIn
        Implements IDexterityAddIn
    
    
        ' IDexterityAddIn interface
    
    
        Sub Initialize() Implements IDexterityAddin.Initialize
    
    
        End Sub
    
    
    End Class

    Here's the first thing that you should try:

     Imports Microsoft.VisualBasic
    Imports System
    Imports System.Collections
    Imports System.Collections.Generic
    Imports Microsoft.Dexterity.Bridge
    Imports Microsoft.Dexterity.Applications
    
    
    Public Class GPAddIn
        Implements IDexterityAddIn
    
    
        ' IDexterityAddIn interface
    
    
        Sub Initialize() Implements IDexterityAddin.Initialize
            AddHandler Dynamics.Forms.SopEntry.SopEntry.OpenAfterOriginal, AddressOf test
    
    
        End Sub
    
    
        Sub test(ByVal sender As Object, ByVal e As System.EventArgs)
            MsgBox("hello world")
        End Sub
    End Class

    Build your project, and copy the contents of the DEBUG folder to Dynamics/GP/addins. Launch Dynamics and open the SOP entry form, you should see the message box that we coded above.

    The method that you're calling has to have a specific signature. The signature varies by the event that you're trapping. If it is a 'before' event, you'll have a 'cancelEventArgs' param. You can get the signature like this:

     

    Coding custom (modified) objects 

    Next, we'll add an event handler for some specific custom events - we'll add a custom button and text box can code up events for that.  

    Add a button and a custom field to a form through Modifier. Here, I've added a supervisor field and lookup button to the Payroll Employee Maintenance form

    After adding the button and text field, close Dynamics and run dag.exe to create the modified forms dictionary. Here's the line that I use:

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

    You'll get this:

     

    This process is VERY memory intensive. You'll need 2 gb or risk a timeout or crash.

    After this runs, you'll have two new files in the Dynamics/GP folder: Application.MicrosoftDynamicsGP.xml and Application.MicrosoftDynamicsGP.dll. Copy these files to your bin folder and set a reference to them.

     

     

     

     

    Steve Gray, MCDBA
    Technical Editor
    steve@VSToolsForum.com
    • Post Points: 0
Page 1 of 1 (1 items)