Map Values from Lists using AX 2012 SysListPanelRelationTableCallback

by | Updated August 15, 2016 | Development, Dynamics AX

Dynamics Ax 2012 contains a class called SysListPanelRelationTableCallback that helps you build a UI to associate values from two lists. This is used by the User Groups (SysUserGroupInfo) and Server Configuration (SysServerConfig) forms among others. For purposes of this example, assume we are working on a feature that limits the valid currencies for any given country. We will build a form that allows us to associate a list of currencies with each country.

First, we need to create a table to hold the mappings. We’ll call this table CountryCurrency to indicate that it is an association table between Countries and Currencies. This table will need to contain the primary key fields from both tables. Right click the Relations node on the CountryCurrency table and choose “New Relation”.  Enter LogisticsAddressCountryRegion in the Table property. Now right click the relation and choose “New/ForeignKey/PrimaryKey based” to create a foreign key relationship to the table. This will add the necessary fields to our table. Now do the same for the Currency table. Finally, create an alternate key index on the CountryCurrency table containing both of these fields.

AOT Data Dictionary Table

Now we need to create a form that allows the user to create the map. In the AOT, right-click on the Forms node and choose “New Form from template/SimpleListDetails.”  This will give us a form with a little head start. Rename the form CountryCurrency to match the table. Create a Data Source for the LogisticsAddressCountryRegion table and bind it to the grid (Design/Body/GridContainer/Grid).  Add string controls bound to the CountryRegionId field and displayName display method to the grid. Then find the DetailsTab tab control and change the Style property to “Tabs” and set ShowTabs to “No.” If you run the form now you should have something that looks like this.

Country and Description

Now we will add the SysListPanelRelationTableCallback class to handle the rest of the UI.

Add a member variable named listPanel to the form.

Override the init method on the form so we can setup the tables that will be used in the mapping.

Now we will implement the getRightData method to populate the right data list.

If we were to re-write this select statement using the values from the form’s init method, it would look something like this.

The only thing left to do is tell the SysListPanelRelationTableCallback class when our “Left” value has changed so it can update itself.  To do this we will override the LogisticsAddressCountryRegion data source’s active method like this.

Now when you run the form you should see something like this.

Allowed Currencies

To map a currency to the current country, select it and press the “<” button.

Allowed Currencies

If you open your CountryCurrency table with the Table browser you will see it contains the 2 association records mapping the AED and AMD currencies with Aruba. The SysListPanelRelationTableCallback class is handling the mapping table records for us. If we map a value it will insert it into the map, and if we un-map a value, it will remove it from the map.

Table Browser

 

Related Posts

  • In AX 2012 you can set the value for a specific dimension using code similar to what is below. DimensionAttributeValue         dimAttrValue; DimensionAttribute              dimAttr; DimensionAttributeValueSetStorage davss; RecId                defaultDimension; davss = DimensionAttributeValueSetStorage::find(this.DefaultDimension); dimAttr…

  • **Updated 11/20/2013** There are quite a few important keyboard shortcuts that can really save some time when entering data and moving around in AX 2012.  One in particular - hitting…

  • The much anticipated release of AX 2012 R2 has been announced. Here are the new features that have my attention. I'll be sure to post some detail, as I explore…

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

Upcoming Events

september

02sep10:00 am10:30 amThe Modern Manufacturer - Cycle Count Management

02sep12:00 pm12:30 pmBest Practices for Work Order Planning and Routing for Field Service Companies

09sep10:00 am11:00 amWhat is Levridge? An Overview of the Ultimate Ag Solution

09sep12:00 pm12:30 pmOverview of Microsoft Promotion for NAV and GP Clients

10sep11:00 am12:00 pmConfab with Stoneridge - Livestream - Field Service Comparisons

16sep10:00 am10:30 amThe Modern Manufacturer - Product Lifecycle Management

16sep12:00 pm12:30 pmHow to Upgrade to Dynamics 365 Finance and Operations: Examining Custom Code and ISV Implications

16sep2:00 pm2:30 pmScheduling and Dispatching for the Modern Field Service Company

23sep12:00 pm1:00 pmDynamics 365 Business Central Wave 2 Release Preview - An Overview of the Most Exciting New Features Coming in October

24sep11:00 am12:00 pmConfab with Stoneridge - Livestream - The Modern Workplace: Teams, Sharepoint, Outlook, Office, and AI Integration

30sep10:00 am10:30 amThe Modern Manufacturer - Return Management

30sep12:00 pm12:30 pmEmpowering Your Field Service Technicians with a Mobile Solution

october

07oct12:00 pm1:00 pmThe Three Paths to Business Central from Dynamics GP

08oct11:00 am12:00 pmConfab with Stoneridge - Livestream - The Vision and Strategy of Microsoft Business Systems

14oct10:00 am10:30 amThe Modern Manufacturer - Complex Cost Modeling

14oct12:00 pm12:30 pmGenerating Custom Inspection or Process Forms

19octAll Day22Stoneridge Connect Fall 2020

22oct11:00 am12:00 pmConfab with Stoneridge - Livestream - Stoneridge Connect Recap

28oct10:00 am10:30 amThe Modern Manufacturer - Engineering Change Orders

About Stoneridge
Stoneridge Software is a unique Microsoft Gold Partner, with emphasis on partner. With specialties in Microsoft Dynamics 365, Microsoft Dynamics AX, Microsoft Dynamics NAV, Microsoft Dynamics GP and Microsoft Dynamics CRM, we focus on attracting the most knowledgeable experts in the field to our team, and prioritize delivering stellar solutions with maximum impact for your business. At Stoneridge, we are deeply committed to your results. Each engagement is met with a dedicated team, ready to provide thorough, tailored, and expert service. Based in Minnesota, we intentionally “step into your shoes,” wherever you are. We focus on what you care about, and develop trusting, long-term relationships with our clients.

Subscribe To Our Blog

Sign up to get periodic updates on the latest posts.

Thank you for subscribing!

X