#GPPT Using GP Power Tools to fix GP Power Tools

David Meego - Click for blog homepageWith the release of the ISV Drop of Microsoft Dynamics GP v18.6 yesterday. I went through the process of creating Pre-Release Beta builds of the Winthrop Development Consultants products.

One of the issues I came across with the update of GP Power Tools was that the parameters of a form procedure in Dynamics GP had changed and my code could no longer compile as I was receiving a “Wrong number of arguments to ‘MSGraphEmailSendEmail’.” error.

Here is how I used GP Power Tools to fix the code in GP Power Tools.

One of the features coming in Microsoft Dynamics GP v18.6 (October 2023) release is the ability to use a Shared Mailbox with Multi-Factor Authentication (MFA) when emailing from GP.

Problem

To support this feature, changes were made to the underlying code that handles the MFA calls. The changes must have included adding some parameters to the form procedure: MSGraphEmailSendEmail of form syEmailObj that resulted in my code receiving the error.

To fix this issue, I need to update the code with the correct parameters by adding the new parameters to my call. But how do I know what has changed with the parameters?

At this time, the procedure changes blog for v18.6 has not been published and the source code for v18.6 has not been released to Source Code partners yet. This means that there is no way (without contacting Microsoft) to get the new parameter list.

Unless…. you have GP Power Tools.

Solution

Disclaimer: The method described here works for any procedure or function (global or form) in any product dictionary (Microsoft or ISV) which is exposed to Visual Studio Tools. This is about 95% of the scripts in the product and excludes scripts that pass parameters not supported by Visual Studio Tools, such as anonymous parameters, parameters using complex data types like composites and optional parameters.

Using the GP Power Tools Resource Information window and changing the Resource Type to Procedures & Functions, you can then enter or search for the script in question. Then clicking the Display Parameters button will show the parameter list if it is available.

Here is the parameter list from Microsoft Dynamics GP v18.5:

To find the new parameter list I needed, I installed the buggy (still had compile errors) GP Power Tools build into my Microsoft Dynamics GP v18.6 system, and used the Resource Information window again:

This showed me the two additional parameters and based on their names and datatypes, I decided to add “, false, false” to my code to get rid of the error.

Bonus Technique

I use the same code base for a build of GP Power Tools across all versions of GP that the build will support.

To allow the exact same script in my code to work for v18.3 & v18.4 as well as v18.5 and v18.6 I have used conditional compilation with precompiler directives.

I have the constants in my dictionaries for MBS_PROD_MAJ with the Major version 18 and MBS_PROD_MIN with the Minor version 3, 4, 5, 6 etc.

Here is an example of using conditional compilation:

#if (MBS_PROD_MAJ = 18 and MBS_PROD_MIN >= 7) or (MBS_PROD_MAJ > 18)
    { Code for v.18.6 }
#elseif (MBS_PROD_MAJ = 18 and MBS_PROD_MIN >= 5)
    { Code for v.18.5 }
#elseif (MBS_PROD_MAJ = 18 and MBS_PROD_MIN >= 3)
    { Code for v.18.3 and v18.4 }
#else
    { Code for any other version }
#end if

Note: Another technique that is sometimes useful is using the execute() function to run dynamic Dexterity code that can be different for different versions of GP. This approach is handy when the code changes for a different build that has the same Major and Minor version numbers.

After making the appropriate changes, I was able to complete the v18.6 release of GP Power Tools.

Hope you find this information useful. Remember GP Power Tools can get you parameters for most scripts and conditional compilation allows code to be shared between versions.

And GP Power Tools for v18.6 is available in beta for the developers in the GP community to use.

Enjoy

David

This article was originally posted on http://www.winthropdc.com/blog.

Leave a Reply