最新消息:ww12345678 的部落格重装上线,希望大家继续支持。

[转]AX 2012 Unbound RecId Lookup

网络文摘 William 1831浏览 0评论

Just a simple tip here that Google didn’t turn up a quick answer on.

In 2012, many tables use the RecId field as the Primary Key.  The ‘human readable’ value is then defined using an Index with the Alternate key property set to Yes.

When creating a lookup (dropdown) in this case, you probably need to get the RecId, but want the user to see the Alternate key displayed.

Joris has a great post on how this works when your lookup is on a table that has a foreign key relation to the lookup table. (http://daxmusings.codecrib.com/2011/07/ax-2012-recids-and-unitofwork-foreign.html)

In my case, I was looking to create a simple dialog form with an unbound field (DataSource and DataField properties not set).

My first attempt was to create an Int64Edit control and set the ExtendedDataType (EDT) property.

Of course, this results in this:

Overriding the lookup method can help with the values shown when the dropdown is displayed, but it doesn’t fix that the RecId is shown in the field.

The answer is a new type of control called Reference Group.  (add it to your form just like any other type: right click, New Control, ReferenceGroup)

At first, the Reference Group will be empty, but when you set the ExtendedDataType property, a field is automatically added to the group.  Below I’ve renamed the reference group and set the EDT property.

And the result is:

Nice!

The underlying RecId can be referenced by setting AutoDeclaration to Yes and using value() method on the reference group control.  In the example above, that would be ctrlPlanPeriodRefGroup.value().

转载请注明:ww12345678 的部落格 | AX Helper » [转]AX 2012 Unbound RecId Lookup

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址