Tuesday, August 18, 2009

Use keyboard lookup in Product Builder enumerated fields

In the standard product builder you cannot use Alt-Arrow Down to use the lookup on your enumerated fields. This has been an error since the release in version 3.0 and it doesn't seem like it will be fixed before AX 6.0. So I have looked into how this can be accomplished without too much messing around with the product builder.

The reason that you cannot use the lookup from the keyboard is that the AX kernel reasonably enough decides that there is no point in activating the lookup. The key problem is simply to make the kernel accept that there is a point in activating the lookup.

All the enumerated field is based on the table field \Data Dictionary\Tables\PBATmpBuildForm\Fields\tmpString which again is based on the extended data type PBATmpString. The extended data type has no relations on it, and that's the simple reason that the kernel won't activate the lookup.

So to make the kernel activate the lookup I have created a new table, PBASupportEnumLookup, which the extended data type now has a relation to.

Now the kernel will activate the lookup, but it will also try to validate the entered enum values against this table. So I must insert all enum values to the new PBASupportEnumLookup table. I do that in validateField of PBATmpBuildForm before validating the field entry.

The validation part would not be needed if I could get this to work with table relations, because on a table relation I can set the Validate property to no. But unfortunately, a table relation is not enough to make the kernel run the lookup.

Everything else is handled by the product builder code, which already works fine if users in standard use the mouse to open the lookup....

Adding the enum entries to a new table is obviously not the most desirable solution, but it works and it works with minimal footprint in the standard code base. And the users are happy!