#GPPT Unknown Identifier Error when working against Modified windows


David Meego - Click for blog homepageDexterity is the native language of Microsoft Dynamics GP. It is an amazing development environment that is still the best and most powerful tool to integrate with the Dynamics GP User Interface. While Dexterity was originally developed in the late 1980’s, it has been continuously developed and extended with more and more features and functionality which allow it to handle everything needed for modern business applications AND still be completely backwards compatible to its original release.

However, Dexterity does have some limitations: It is a little bit more complex if you need to integrate with other third party dictionaries and it cannot work with modified windows. GP Power Tools extends Dexterity’s scripting capabilities to make it possible to easily work with multiple dictionaries and with modified windows.

This article addresses a specific issue that can occur when using GP Power Tools’ ability to compile and execute scripts against modified versions of a window.

As mentioned earlier, standard Dexterity cannot “see” modified windows and so will give the error: Unknown Identifier whenever you attempt to use a modifier added field (that is a local field added using Modifier).

GP Power Tools uses some special techniques to allow Dexterity scripts in both the Trigger Setup and Runtime Execute Setup windows to run in the context of the modified dictionary, which means that the compiler can now “see” the modifier added field and the script will compile and execute as desired. Selecting the Modified checkbox next to the dictionary context enables this mode.

On both of these GP Power Tools windows, pressing Ctrl-S for Save and Continue will check the script syntax before saving or you can use the Check Syntax option from the Script menu.

The Problem

The issue that has been found is a bug in the Dexterity compiler when working in Modified mode. If there is any compile time error in the script that occurs in the script after a reference to a modifier added field, the error message: Unknown Identifier for the modifier added field will be returned.

This incorrect error message will be returned regardless of what the true error actually is and so can make debugging difficult as it does not help identify the true problem.

For example (using the ITEM URL SAVE script from the #GPPT Beginner’s Guide to Adding Custom Fields series):

We have the following lines which compile without errors:

MBS_ObjectID = 'Item Number' of window 'IV_Item_Maintenance' of form 'IV_Item_Maintenance';
MBS_Property = '(L) URL' of window 'IV_Item_Maintenance' of form 'IV_Item_Maintenance';
if not empty(MBS_Property) then

Let’s introduce some errors and see what happens. For example let’s change the first instance of the variable MBS_Property to MBS_Property1:

MBS_ObjectID = 'Item Number' of window 'IV_Item_Maintenance' of form 'IV_Item_Maintenance';
MBS_Property1 = '(L) URL' of window 'IV_Item_Maintenance' of form 'IV_Item_Maintenance';
if not empty(MBS_Property) then

Pressing Ctrl-S to compile, save and continue generates the error:

But if we change the second instance instead from MBS_Property to MBS_Property1:

MBS_ObjectID = 'Item Number' of window 'IV_Item_Maintenance' of form 'IV_Item_Maintenance';
MBS_Property = '(L) URL' of window 'IV_Item_Maintenance' of form 'IV_Item_Maintenance';
if not empty(MBS_Property1) then

It generates the incorrect error as the error is after the reference to a modifier added field, ‘(L) URL’:

Another example. If we add an exclamation mark (!) which means NOT in other languages (but not Dexterity) before the equals sign:

MBS_ObjectID != 'Item Number' of window 'IV_Item_Maintenance' of form 'IV_Item_Maintenance';
MBS_Property = '(L) URL' of window 'IV_Item_Maintenance' of form 'IV_Item_Maintenance';
if not empty(MBS_Property) then

The compiler generates the following Syntax Error:

However, if we swap the two assignment lines around, like so:

MBS_Property = '(L) URL' of window 'IV_Item_Maintenance' of form 'IV_Item_Maintenance';
MBS_ObjectID != 'Item Number' of window 'IV_Item_Maintenance' of form 'IV_Item_Maintenance';
if not empty(MBS_Property) then

Now the compiler will generate the incorrect error on the modifier added field again as the error is after the reference to a modifier added field:

One last example. If we change the datatype for the data we are trying to assign to MBS_ObjectID by adding a value() function:

MBS_ObjectID = value('Item Number' of window 'IV_Item_Maintenance' of form 'IV_Item_Maintenance');
MBS_Property = '(L) URL' of window 'IV_Item_Maintenance' of form 'IV_Item_Maintenance';
if not empty(MBS_Property) then

The compiler generates the expect Type incompatibility (Type Mismatch) error:

But if we add the value() function on the ‘(L) URL’ modifier added field instead:

MBS_ObjectID = 'Item Number' of window 'IV_Item_Maintenance' of form 'IV_Item_Maintenance';
MBS_Property = value('(L) URL' of window 'IV_Item_Maintenance' of form 'IV_Item_Maintenance');
if not empty(MBS_Property) then

We get the incorrect error message again:

Hopefully, this demonstrates the issue well enough.

The Solution

While it is not possible to actually fix the problem with the compiler, there are methods that can be used to help debug these issues. Below are a few ways to narrow down and fix the issue.

  1. Comment out the line containing the modifier added field. Ensure that the code compiles without any errors. Then restore the commented out line and compile again.
  2. Edit the reference to the modifier added field to another window field of the same datatype. Using another local field is usually easiest. Don’t forget to restore the field name once the code compiles.
  3. If you still have issues, use additional local variables for any intermediate steps so that the final reference to the modifier added field is just field = variable or variable = field. That makes it simple to perform method 1 (above) and ensure that the rest of the code is getting syntax checked.

Further Information

As Dexterity is unable to “see” modifier added fields, the Resource Information and Resource Explorer windows in GP Power Tools can only include fields from the original versions of the windows.

If you are interested in learning Dexterity, please contact us, we usually run training in the week before the GPUG Summit conferences. Having knowledge of Dexterity will help improve the effectiveness and efficiency anyone who works as a developer of integrations for Microsoft Dynamics GP, regardless of whether they plan to work with Dexterity, Visual Basic for Application, Visual Studio Tools for Microsoft Dynamics GP or GP Power Tools.

You can also check out the link below for the full series demonstrating how to work with custom fields.

Hope you find this information useful.

David

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

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.