Opening a native GP form from VS addin
This post covers a self help pattern, to assist developers wishing to open a native GP form from .NET using Visual Studio Tools For GP addin.
An example is needed to work with, say it was required to open the Manufacturer’s Item Number Maintenance form from our .NET code:
This form is normally only available from the Item Purchasing Options Maintenance Form but in this example it is required to launch it from our .NET code.
Identify the form name
Using the title caption from the form, go into Tools>Customise>Modifier to find the name of the form, or use the resource tool found under Tools>Resource Descriptions>Windows
IF using the resource tool, the product should be selected to which the form belongs, in this example Microsoft Dynamics GP, set Series Inventory, set View by display name.
Here we can see its called IV_MFG_Item_Nmbr_Mnt internally. Forms have display and internal names.
By typing in Visual Studio the window can be located by following intellisense, starting at the dictionary it belongs to (MicrosoftDynamicsGP) and taking out the underscores from the Dex name found above as it is typed.
Once the form is located, put a period after the form name to see what procedures it supports, typing “open” flushes out the procedures of interest.
It can be seen that to open the form, this form uses: OpenIvMfgItemNmbrMntProcedure
Intellisense also guides as to how to call it using _Instance.Invoke![image](https://timwappat.info/content/images/image_thumb_33.jpg "image")
However, a familiar issue is hit at this point. The open procedure requires two parameters passing. What are the two parameters that intellisense is asking for? Luckily help is at hand, from the tooltip (see image above),
Invokes form procedure “Open_IV_MFG_Item_Mnt” of form “IV_MFG_Nmbr_Mnt”
Thus recalling that all that is happening here is a call down to procedures in the underlying dexterity code, we can find what we need to call this by checking the Software Developer Kit (SDK).
You of course have the GP SDK installed? – if not get it now…
Using the SDK to find parameters
Searching on the SDK folder, C:\program Files\Microsoft Dynamics\GP11.0 SDK\Content for the start of the procedure name “Open_IV_MFG” a hit is returned in a file called “CoreForms_1100.txt”
Opening CoreForms_1100.txt, and search for the same term. The following text is found in the document …
INVENTORY FORM PROCEDURE: Open_IV_MFG_Item_Nmbr_Mnt
of form IV_MFG_Item_Nmbr_Mnt
in 'Item Number' l_item;
in 'Item Description' l_Description;
So the two parameters needed are Item Number and Item Description.
So now we call it like this:
MicrosoftDynamicsGpDictionary.IvMfgItemNmbrMntForm.OpenIvMfgItemNmbrMntProcedure._Instance.Invoke("testpart", "testpart description")
Compile, deploy and you should find the form opens with the item selected!