30 September, 2009

Avoid some GP Form Modifications with VSTools

I've been doing a lot of work with Visual Studio Tools lately and find myself migrating more towards that from VBA. VSTools is not a replacement for VBA but in some cases can prove to be a more effective tool.

Modifying a Form in GP is often a simple thing to do with few repercussions if planned and executed properly. One drawback to a form modification is that you have to upgrade the modified forms even when applying service packs. This makes the service pack application and upgrade processes slightly more cumbersome. Not a big deal but another step in the process that in some instances you might be able to avoid. Some of my existing clients are starting to request VSTools customizations over VBA partly for this reason.

While this isn't always applicable, you can't modify a GP Form with VSTools after all, you can sometimes leverage the VSTools .AddMenuHandler method in place of modifying a form in GP. You can find more information about the .AddMenuHandler on page 71 of the VSTDGPProgrammersGuide.pdf.

Here's an example of how to use the .AddMenuHandler method instead of modifying a GP Form:

Below is the code to add an Additional Menu Handler that when executed calls a function that will retrieve the next numeric Fixed Asset ID and populate the Asset ID in the Asset General Information Window.

Dim FANextNumericID As System.EventHandler


Sub Initialize() Implements IDexterityAddIn.Initialize


     FANextNumericID = New System.EventHandler(AddressOf FAGetNextNumericID)
     FixedAssets.Forms.FaGeneralMaintenance.AddMenuHandler(FANextNumericID, "Next Asset ID", "N")


End Sub


Now, in GP you can simply use the Ctrl-N hotkey or select Next Asset ID from the Additional Menu…



… to assign the Next Numeric Fixed Asset ID to new Fixed Asset Record.



Now, not only do you not have to deal with merging Form Modifications and/or VBA code with existing Form Modifications or VBA projects but if there weren't any to begin with you don't have to deal with upgrading them when applying services packs or upgrading.

2 comments:

Mariano Gomez said...

Great article! You picked up where I left off (due to many commitments) with the Visual Studio Tools series.

I am starting to favor VST over VBA as well, as the release to production process is much much more simplified than that of VBA. In fact, another issue with VBA is, you can only import package files when ALL users are out of the system, hence having no locks on the forms dictionary. Not good for 100 users.

MG.-

smitha said...

really amazing blog and I was thankful to you for sharing such a useful information.
- CRM Solutions