Tuesday, January 26, 2010

Changing the Hyperspace property for a lookup button added with Modifier

It sounds like some word out of Captain Kirk's vocabulary, but for Dexterity developers Hyperspace is a well known property that allows a Dexterity-based application to run the change script for a push button, i.e., a lookup button, without moving the focus from the currently-selected field. For example, you won't want the 'Customer Number' field on the Customer Maintenance window to execute it's change script before you have selected a customer from the Customer Lookup window as the lookup button is clicked... that's what Hyperspace does, it prevents such situations by keeping the focus on the 'Customer Number' field until a customer ID is returned from the lookup window into the field.

The problem is, this property is locked down for push button controls added with Modifier, and while you cannot edit the push button change script with Modifier, you may still want to trigger off such controls with Dexterity code. This is pretty common for customizations where you don't want to create an alternate versions of a GP form, but require a control placed directly on the GP form in order to call your own Dexterity code (see my article Developing Microsoft Dynamics GP hybrid integrating applications).

So, here is the workaround for changing the Hyperspace property of a push button control added with Modifier:

1. Add the push button control to your Modified window. In my example I will be using the sopCustomerItemMnt form. The following illustrates the changes made:



2. Save your modified window and return to Microsoft Dynamics GP. Open the Customization Maintenance window and locate the sopCustomerItemMnt. Click the Export button to export the modified window to a package file. The following is the content of exported package file:



= Form "sopCustomerItemMnt"
{
Datatypes
{
Datatype "Lookup"
{
Control "PushButton"
DefaultDown "00000"
DefaultMouseOver "00000"
DefaultUp "00000"
Prompt ""
PromptDown ""
PromptMouseOver ""
StaticType "Mixed"
~ItemImages
{
PictItem "00001"
{
Item "Field_Lookup_PB_Up"
}
}
}
Datatype "UPC_Code"
{
AllowOddLength "false"
Control "String"
Format ""
KeyableLength "31"
StorageLength "32"
}
}
Fields
{
Field "Lookup"
{
ArraySize "0"
Datatype "(L) Lookup"
LookupForm ""
PhysicalName ""
}
Field "UPC_Code"
{
ArraySize "0"
Datatype "(L) UPC_Code"
LookupForm ""
PhysicalName ""
}
}
Windows
{
= Window "sopCustomerItemMnt"
{
Fields
{
WindowControl "(L) Lookup"
{
Alignment "center"
Appearance "2D Border"
BackColor "System - Button Face"
Border "true"
ButtonStyle "GraphicOnly"
Cancel "false"
ControlType "PushButton"
Default "false"
Editable "true"
EndTransaction "false"
Field "(L) Lookup"
Font "System (generic)"
FontBold "false"
FontColor "System - Button Text"
FontItalic "false"
FontUnderline "false"
HyperSpace "false"
LinkedLookup "10002"
LinkedPrompt "0"
Pattern "(none)"
PatternColor "White"
PositionLeft "567"
PositionTop "186"
ResizeHoriz "StayLeft"
ResizeVert "StayTop"
SizeHeight "20"
SizeWidth "18"
TabStop "true"
Tag "10003"
Tooltip ""
UseUniqueHelp "true"
Visible "true"
ZOrder "81"
Zoom "false"
}
WindowControl "(L) UPC_Code"
{
Alignment "left"
Appearance "2D Border"
AutoComplete "false"
AutoCopy "false"
BackColor "System - Window Background"
Border "true"
ControlType "String"
DisableLookup "false"
Editable "true"
Field "(L) UPC_Code"
Font "System (generic)"
FontBold "false"
FontColor "System - Window Text"
FontItalic "false"
FontUnderline "false"
LinkedFormat "0"
LinkedLookup "0"
LinkedPrompt "10001"
Password "false"
Pattern "(none)"
PatternColor "White"
PositionLeft "408"
PositionTop "186"
ReadingOrder "LeftToRight"
Required "false"
ResizeHoriz "StayLeft"
ResizeVert "StayTop"
SavedOnRestart "false"
SetChangeFlag "true"
SizeHeight "20"
SizeWidth "160"
TabStop "true"
Tag "10002"
Tooltip ""
UseUniqueHelp "true"
Visible "true"
ZOrder "80"
Zoom "false"
}
WindowPrompt "10001"
{
Alignment "left"
Appearance "3D Highlight"
BackColor "System - Button Face"
Border "true"
Font "System (generic)"
FontBold "false"
FontColor "System - Button Text"
FontItalic "false"
FontUnderline "false"
Pattern "(none)"
PatternColor "White"
PositionLeft "328"
PositionTop "186"
ReadingOrder "LeftToRight"
ResizeHoriz "StayLeft"
ResizeVert "StayTop"
SizeHeight "20"
SizeWidth "80"
Text "UPC Code"
Visible "true"
ZOrder "79"
Zoom "false"
}
}
LastTag "10003"
}
}
}

3.Perform a search for "Hyperspace". Replace the property value from false to true. Save the package file. In the above sample package file content, I have highlighted the Hyperspace property in red.

4. Use the Customization Maintenance window to reimport the package file. This should be all! Now your lookup button's hyperspace property is set to true.

Warning: this method of changing the Hyperspace property of a push button is not supported by Microsoft and must be performed by a developer who understands the implications.

Until next post!

MG.-
Mariano Gomez, MIS, MCP, MVP
Maximum Global Business, LLC
http://www.maximumglobalbusiness.com/

No comments: