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!


Mr. Denize said...

Hi Palle - another solution could be to add PBAVariableEnumLookup to the FormHelp property of the enum. This will have the same result as your solution.

Anonymous said...

I used the task-method to fetch calles to ctrl+arrowdown with taskId = 1315 and if the selected control is of type enum I call the enumlookup method in the form pbafrontend...

Kind regards,

Palle Agermark said...

Mr. Denize,

That's a much simplet solution :-) I'll try that when I get a chance.

As to the Task method, I wasn't able to catch anything here. But the controls associated with the Product Builder enumerated fields are, as I recall it, not enum type fields, but string controls.

Anonymous said...

Hi again,

have a look here, if you need any hint:

The enumeration in pba is a string control.