ENTERPRISE

Microsoft Dynamics AX 2009 : Building Lookups - Creating an automatic lookup

9/15/2012 2:52:56 AM
Standard Dynamics AX lookups can be created in seconds without any programming knowledge. They are based on table or extended data type relations. If the relation is set on an extended data type, then all tables using this type will have automatic lookups based on extended data type. For example, if we look at the ItemId extended data type, we see that it is related to ItemId field in InventTable table. That means every control in the system bound to this extended data type will have automatic lookup to the InventTable table. It is also possible to override extended data type relations by specifying relations on the table itself. In this case, lookup will be based on the relations of the table. For example, we can create some relation on the SalesLine table and extend it to have an additional related fixed field ItemType equal to 2. In this case, all controls bound to the ItemId field in the SalesLine table will have a lookup showing only items of type 2, i.e. service.

As an example, we will create a default customer method of payment in the Customer group form.

How to do it...

  1. 1. Open the CustGroup table in AOT, and add a new field:

    Property Value
    Type String
    Name PaymMode
    ExtendedDataType CustPaymMode

  1. 2. Add the newly created field to the end of the Overview field group of the table.

  2. 3. To check the results, open Accounts receivable | Setup | Customer groups, and notice a new Method of payment column with the lookup:

How it works...

The newly created PaymMode field extends the CustPaymMode extended data type that has a defined relation to the CustPaymModeTable table. This relation ensures that our field and its form control have automatic lookup. By adding this field to the Overview field group, we make sure that it appears automatically in the Customer group form's grid in the Overview tab page.

There's more...

The automatically generated lookup, in the example above, has only two columns— Method of payment and Description. Dynamics AX allows us to add more or change existing columns with minimum effort by changing various properties. Lookup columns can be controlled at several different places:

  1. 1. Relation fields, either on an extended data type or a table itself, are always shown on lookups as columns. In our example, the extended data type CustPaymMode has a relation with PaymMode field in the CustPaymModeTable table and that's why it is displayed on the lookup.

  2. 2. Fields defined in table TitleField1 and TitleField2 properties are also displayed as lookup columns. We can see that Method of payment is specified in TitleField1 of the CustPaymModeTable table and Description is specified in TitleField2.

  3. 3. The first field of every table index is displayed as a column. If we look again in our example, we can see that the CustPaymModeTable table contains an index CustPaymModeIdx, which consists of the PaymMode field. This field is displayed as a lookup column.

  4. 4. The index fields, TitleField1 and TitleField2, are in effect only when the AutoLookup field group of the table is empty. Otherwise, the fields defined in the AutoLookup group are displayed as lookup columns.

Duplicate fields are shown only once. In our example, we can see that TitleField1 is set to PaymMode and TitleField2 is set to Name. The extended data type relation is based on the PaymMode field, which is the same as TitleField1. The only index, CustPaymModeIdx also contains the PaymMode field. That means our lookup will have only two columns— PaymMode (labeled as Method of payment) and Name (labeled as Description).

Now, to demonstrate how the AutoLookup group can affect lookup columns, let's modify the previous example by adding another field to this group. Let's add the PaymAccount field to the AutoLookup group on the CustPaymModeTable table. Now, the lookup has one more column:

In this way we can quickly add more fields into lookups.

It is also possible to add display methods to the lookup's column list. We can extend our example by adding the paymAccountName() display method to the AutoLookup group on CustPaymModeTable. And here is the result:

Other  
  •  Introducing Our New Zero-Point
  •  Exchange Server 2010 Administration Overview (part 3) - Using the Graphical Administration Tools, Using the Command-Line Administration Tools
  •  Exchange Server 2010 Administration Overview (part 2) - Exchange Server and Windows,Exchange Server and Active Directory
  •  Exchange Server 2010 Administration Overview (part 1) - Exchange Server 2010 and Your Hardware, Exchange Server 2010 Editions
  •  Touch Screens Are Everywhere
  •  Intel Builds Bridge to Next - Generation Macs
  •  Microsoft vs. Google vs. Apple: Who will win?
  •  Phone Business: The Age Of Convergence
  •  Microsoft Visual Basic 2008 : Services That Listen - Allowing Multiple Connections
  •  Microsoft Visual Basic 2008 : Services That Listen - Listening with TCP/IP
  •  Seagate GoFlex Satellite Wireless
  •  Toshiba MQ01ABD100 1TB Hard Drive
  •  View Quest Retro WI-FI Radio
  •  Microsoft Enterprise Library : Non-Formatted Trace Listeners (part 3) - Adding Additional Context Information, Tracing and Correlating Activities
  •  Microsoft Enterprise Library : Non-Formatted Trace Listeners (part 2) - Logging to a Database, Testing Logging Filter Status
  •  Microsoft Enterprise Library : Non-Formatted Trace Listeners (part 1) - Creating and Using Logentry Objects, Capturing Unprocessed Events and Logging Errors
  •  Introducing Windows Presentation Foundation and XAML : Transforming Markup into a .NET Assembly
  •  Introducing Windows Presentation Foundation and XAML : Building a WPF Application using Only XAML
  •  Intel : We For One Welcome Our Apple Overlords
  •  Azure Table Storage (part 2) - Accessing Table Storage, Choosing a PartitionKey, Exception handling
  •  
    Most View
    Iwork Pro - Sharing A Cell
    The Best Overlocked PCs On The Market (Part 2)
    AMD Trinity the Chip to Take down Core i3? (Part 2)
    So You Want To Work In... Virtualization
    G.Skill DDR3 SDRAM 32GB Review (Part 1)
    Improve Your Mac (Part 8) - Master OS X Reminders
    MSI FM2-A85XA-G65 Motherboard Review (Part 2)
    Cat B15 Rugged Android Smartphone Hands-On
    Top 10 Camcorders - Jan 2013
    Top 10 Smartphone Apps - Q1 2013
    Top 10
    Windows Management and Maintenance : The Windows 7 Control Panel (part 11) - Region and Language, System
    Windows Management and Maintenance : The Windows 7 Control Panel (part 10) - Programs and Features
    Windows Management and Maintenance : The Windows 7 Control Panel (part 9) - Notification Area Icons, Performance Information and Tools
    Windows Management and Maintenance : The Windows 7 Control Panel (part 8) - Fonts
    Windows Management and Maintenance : The Windows 7 Control Panel (part 7) - Ease of Access Center
    Windows Management and Maintenance : The Windows 7 Control Panel (part 6) - Devices and Printers
    Windows Management and Maintenance : The Windows 7 Control Panel (part 5) - AutoPlay
    Windows Management and Maintenance : The Windows 7 Control Panel (part 4) - AutoPlay
    Windows Management and Maintenance : The Windows 7 Control Panel (part 3) - Action Center
    Windows Management and Maintenance : The Windows 7 Control Panel (part 2)