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

march

03mar10:00 am10:30 amThe Modern Manufacturer - MRP vs. MPS – What, When and How

03mar2:00 pm2:30 pmLot Management Best Practices for Batch Manufacturers

10mar10:00 am10:30 amEnhancing the Customer Experience and Driving More Business with Dynamics 365 Customer Service

10mar2:00 pm2:30 pmThe Five Steps to Managing Sales Tax for Manufacturers

11mar11:00 am12:00 pmConfab with Stoneridge - Livestream - Power Apps Component Framework Power Hour

17mar10:00 am10:30 amThe Modern Manufacturer: Pro Tips for your Finance Team

24mar10:00 am10:30 amUnlock the Potential of Digital Marketing with Dynamics 365 Marketing

25mar11:00 am12:00 pmConfab with Stoneridge - Livestream - The Four Keys to Choosing the Best ERP or CRM Solution

31mar10:00 am10:30 amThe Modern Manufacturer: Keys to Reporting Success

31mar01aprTraining Class: Financial Reporting W/Account Schedules for Dynamics 365 Business Central

april

31mar01aprTraining Class: Financial Reporting W/Account Schedules for Dynamics 365 Business Central

07apr10:00 am10:30 amBoost Seller Productivity and Close More Business with Dynamics 365 Sales

07apr2:00 pm2:30 pmEnsuring Quality for Batch Manufacturers

08apr11:00 am12:00 pmJumping into the Deep End of the Data Lake

14apr10:00 am10:30 amThe Modern Manufacturer: Cost Accounting in D365

22apr11:00 am12:00 pmMoving from Manual to Automated with Strategic Automation Strategies

28apr10:00 am10:30 amThe Modern Manufacturer: Best Practices for Inventory Turn

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