Hybrid - Setting a push button to Hyperspace

Patrick Roth - Click for blog homepageTrivia 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.

Answer:

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 String
    
    Set 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.

 

Regards,

 

Patrick

Dynamics GP Developer Support 

// Copyright © Microsoft Corporation. All Rights Reserved.
// This code released under the terms of the
// Microsoft Public License (MS-PL, https://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.