Dynamics.Application Object not available on Web Client

David Meego - Click for blog homepageThis article comes about because we have identified a feature of GP Power Tools that does not work as expected on the Web Client. GP Power Tools has the ability to run scripts and register triggers against Modifier added fields and Modal Dialogs. These features uses the Dynamics.Application object and in particular a suite of functionality historically known as “Continuum”.

We can now confirm that the Dynamics.Application object is not available at all when running Microsoft Dynamics GP in the Web Client and so any functionality reliant on this object will fail to work.

This means that while the current design of the GP Power Tools features for referencing Modifier added fields or Modal Dialogs will work in the Desktop Client, they will not work in the Web Client. There are some alternate methods which should work with the current Build 27 code and will be described in an upcoming article. We are also looking at enhancing GP Power Tools to make the alternate methods even simpler to use.

[Edit] The upcoming GP Power Tools Build 28 no longer uses “Continuum” and so no longer is affected by the limitations this caused.

However, the main purpose of this article is actually to ensure that .Net developers are aware of this limitation, now that it has been identified.

A commonly used method for .Net developers is to call Dexterity and execute passthrough SanScript code using the Dynamics.Application object with code similar to the C# and VB.Net examples below:

string CompilerMessage = "";
short CompilerError = 0;
 
Dynamics.Application CompilerApp = new Dynamics.Application();
 
CompilerApp.CurrentProductID = 0;
CompilerError = CompilerApp.ExecuteSanscript("warning \"Hello World.\"; ", out CompilerMessage);
 

or

Dim CompilerMessage As String = Nothing
Dim CompilerError As Integer = 0
 
Dim CompilerApp = New Dynamics.Application()
 
CompilerApp.CurrentProduct = 0
CompilerError = CompilerApp.ExecuteSanscript("warning ""Hello World.""; ", CompilerMessage)
 

After discussions with my friends in the Dexterity Development team in Fargo, it was confirmed that the Dynamics.Application object is not initialized in the Web Client.

The reasoning is that Dynamics.Application is a COM (Component Object Model) object and when you reference it in your code you are normally connected to the first instance of that object associated with the first launched instance of Microsoft Dynamics GP.

Because the Web Client intentionally starts a new instance of the Microsoft Dynamics GP runtime for each client process, there is no way that the COM object could be guaranteed to be associated with the correct instance of the GP runtime. The decision was made that it was safer not to initialize the Dynamics.Application object at all.

If you try to use the above methods in your code, it will force the Dynamics.Application object to initialize. But it will spin up a new runtime engine that is not associated with any existing instance and will not have a launch file specified. Just like if you launched Dynamics.exe without specifying the Dynamics.set parameter.

The call will appear to work and you will not receive an error at the .Net level, but when you call the ExecuteSanscript method, it will not be able to reference any dictionary resources (forms, tables, reports, constants, etc.) and will give “Unknown Identifier” errors for any resource or commands not contained in the runtime engine’s Dex.dic. If you don’t check the returned error count, you will not even realize that your code has failed to execute.

In summary, while most Visual Studio Tools Addins can work on the Web Client as long as they don’t have any .Net user interface elements (WinForms, MessageBox Dialogs, etc.), be warned that passthrough Dexterity SanScript code does not work in the Web Client.

A solution to this issue for Visual Studio Tools developers is to use the latest builds of the free Visual Studio Integration Toolkit product which has over 220 Helper Functions, including a series of Execute functions for running passthrough SanScript with up to 10 optional parameters. These helper functions do not use the Dynamics.Application object and so will function on the Web Client. Because they are using the Dexterity execute() function the scripts will not be able to reference Modifier added fields.

[Edit] Please remember that the helper functions in Visual Studio Integration Toolkit allow Visual Studio Tools developers to perform many Dexterity only functions and so the need for passthrough sanScript to be used is greatly reduced.

Note: GP Power Tools has a list of features that don’t work on the Web Client in Chapter 2 of the User Guide manual. This has been updated to reflect this issue and the latest hotfix gives appropriate warning messages.

Hope you find this information useful.

David

05-Mar-2020: Added reminder that Visual Studio Integration Toolkit’s helper functions mean that passthrough sanScript is probably not needed. Also mentioned triggers on Modal Dialogs which also uses “Continuum”.

08-Apr-2020: Added comment that GP Power Tools Build 28 no longer uses “Continuum”.

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

3 thoughts on “Dynamics.Application Object not available on Web Client

Please post feedback or comments

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.