Hybrid – Setting a push button to Hyperspace

Patrick Roth - Click for blog homepageThis is a reposting of an article Patrick Roth originally wrote on my Developing for Dynamics GP blog.

Trivia question for today:

Given the following sequence of events:

In Microsoft Dynamics GP, in a control field such as Customer Number, the user types in “AARON”. The user then presses the associated lookup button.

What happens?

A. Focus moves to the button causing the field change script to run and validates that Customer Number “AARON” exists.
B. Focus remains on the Customer Number field and the lookup window opens.
C. Both.


B. Focus remains on the Customer Number field and the lookup window opens.

Your experienced GP user will know that this is a ‘feature’ of Dynamics as the user can enter the first few characters to seed the lookup.  When the lookup opens, the window will start to fill from the entered characters making it easier to find the “AARONFIT0001” customer they were looking for.

Bonus points then to those who know why this works?  A hint is that this seems similar to the CausesValidation property in C# for fields.

If you aren’t a Dexterity developer, you probably do not know that this is the Hyperspace property.  The reason is that the Modifier/VBA developers might not be as familiar with this property is because in Modifier we do not let you change this property.  While I can see perhaps that in general this property shouldn’t be changed for existing Dynamics GP buttons, it seems to me that it should be customizeable for a button added by Modifier.

Why would you need to change this property?  Strictly speaking; it isn’t critical that it must be.  However if the developer would like to add their own custom field with validation and a lookup to that field, then you need this.  Otherwise when you click the lookup button – focus leaves the custom field causing the change script to run.  Because potentially only a few characters were entered; validation would fail potentially giving an error message when the user just wanted to use a lookup.

The solution to this is to use a bit of pass through Dexterity via Continuum to change this property.

Dexterity has a function called Field_SetBooleanProperty() which can be used to set quite number of properties.  While every property cannot be set with this function, we’re OK because we can set the Hyperspace property with it.

In this example, I’m assuming the user modified the Customer Maintenance main window to add a new local field called “MyButton” to be the new “lookup” button that the Hyperspace property needs to be set.

A good spot for this type of code would be before or after the window opens.  The code sample below shows how I would code this type of customization using Modifier to add the local button named “MyButton” and the VBA code to change the Hyperspace value to “True”.

Code Example

Private Sub Window_BeforeOpen(OpenVisible As Boolean)
    Dim obj As Object
    Dim ret As Integer
    Dim msg As String, code As StringSet obj = GetObject(, "Dynamics.Application")
    'Switch context to Modified Dynamics window
    obj.CurrentProduct = "Micosoft Dynamics GP!Modified"
    code = "Field_SetBooleanProperty('(L) MyButton' of window RM_Customer_Maintenance of form RM_Customer_Maintenance,FIELD_PROP_HYPERSPACE,true);"
    ret = obj.ExecuteSanScript(code, msg)
    If ret > 0 Then
        MsgBox "sanScript error: " + Chr(13) + msg
    End If
    Set obj = Nothing
End Sub

Note: This customization uses a method of executing Dexterity sanScript code from VBA which is unsupported by Microsoft.


Dynamics GP Developer Support

// Copyright © Microsoft Corporation.  All Rights Reserved.
// This code released under the terms of the
// Microsoft Public License (MS-PL, http://opensource.org/licenses/ms-pl.html.)

27-Jan-2010: Also look at Mariano’s post on the other method of changing the Hyperspace property by editing the package file: Changing the Hyperspace property for a lookup button added with Modifier.

This article was originally posted on the Developing for Dynamics GP Blog and has been reposted 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.