次の方法で共有


Best Practices for Lookup Forms

Applies To: Microsoft Dynamics AX 2012 R3, Microsoft Dynamics AX 2012 R2, Microsoft Dynamics AX 2012 Feature Pack, Microsoft Dynamics AX 2012

Create lookup forms only in situations where the system does not create them automatically. Alternatively, you can design lookup forms by using the AutoLookUp table field group. The form name must be postfixed with 'Lookup'.

If you only need to specify the fields or the query or both, use the functionality in the SysTableLookup class, if possible.

Manually created lookup forms must have the same functionality and general appearance as the lookup forms that are automatically generated by the system.

  • They must support a query expression in the looked up control.

  • They must support "Auto find"/Focus on the rows that are found as characters are keyed in.

Manually created lookup forms can be activated from the FormHelp property on extended data types or from the lookup method on form controls.

Run Method

The code in the run method performs the actual filtering. To avoid flicker in the form, the default query execution is disabled in case of filtering.

In the example below, Common_ds is the datasource in the lookup form and Common_LookupField is the control in the lookup form from which the lookup value is selected, which is the one you used for the 'this.selectmode' call.

Instead of copying the example below, use the filterLookupPreRun and filterLookupPostRun methods in the SysTableLookup class if possible.

void run()
{
    FormStringControl callerControl = 
        SysTableLookup::getCallerStringControl(element.args());
    boolean filterLookup = false;
    if (callerControl.text() && callerControl.hasChanged())
    {
        filterLookup = true;
        Common_ds.autoSearch(false);
    }
    super();
    if (filterLookup)
    {
        Common_ds.research();
        Common_LookupField.filter(callerControl.text());
    }
}

Properties

Property

Property set on:

Value

Description

AllowCheck

Data source

No

Security check must be switched off.

AllowEdit

Data source

No

Not allowed in lookup forms.

AllowCreate

Data source

No

Not allowed in lookup forms.

AllowDelete

Data source

No

Not allowed in lookup forms.

OnlyFetchActive

Data source

Yes

The form will select only the fields that are on the controls in the form. Since there are no codes in lookup forms, they will open faster because the result set is smaller.

Frame

Design

Border

No caption will appear above the form. When the Style is set to Lookup, this property is set for you.

WindowType

Design

Popup

-

ShowRowLabel

Grid

No

For the grid, you must also set the Multiselect property to No and the Border property to None.

See also

Forms Best Practices

How to: Add a Control with a Lookup Form

How to: Add a Run-Time Lookup Form

Announcements: New book: "Inside Microsoft Dynamics AX 2012 R3" now available. Get your copy at the MS Press Store.