Labels Warehouse Management X++

AX2012 : Use queries as criteria

In Dynamics AX 2012 the relation between different records is often defined as a “table-group-all” relation. One example of this is the setup of supplementary items, where you can define the relation as a Table-Group-All relation.

image

Even though this approach is easy to use and understand, it does have limitations.  Often you would like to pin-point the relationships even further.  It can be based on other fields in the source record.

I wanted to look against another approach, where I can use a query as a criteria.  Normally queries are used to fetch specific records based on a set of ranges and defined sorting criteria.

I have a label software, that integrates Dynamics AX 2012 with BarTender, and it is generic, meaning that it can produce labels based on all data sources in AX.

image

So in this case, I can setup that when the user wants to print a label, I can search through a set of label templates, and check this record if it fits the query criteria.  I then have a endless possibility to specify all kinds of criteria to select the best matching label template.

The trick is to add the source recid as a range to the packed query criteria exactly when checking for it.  Also to add the “firstonly” hint, so that you don’t query for more than you want.

Here is some sample job, I used to test out this approach:

image

Microsoft is also using the same approach when selecting is a WMSorder can be added to a existing shipment.  Take a look at  WMSShipment.canWMSOrderBeAdded() or at wmsShipmentTemplate.canWMSOrderBeAdded(), then you see the same pattern.

I hope you see the value in this, and that it can open a complete new way of adding rules and relational information to Dynamics AX 2012.  With this approach we can generically pinpoint our criteria for our rules.

Take care and happy DAXing 

I appreciate that I can be a part of this worldwide blog community—as a consultant working from Norway, the blog lets me share more than 20 years of experience with Microsoft Dynamics 365. Along the way, I participated in developing retail, PDA/RF, barcoding, master data, kitting and WMS-solutions for Dynamics. My blog focuses on my deepest interests and expertise: along with a 360 degree view of digital transformation topics, I welcome opportunities to dive into retail and intercompany supply chain automation, logistics, and production—everything that is moving around in a truly connected enterprise. As Enterprise Architect on Dynamics 365, I specialize in strategic development and planning for corporate vertical solutions and works to build international networks that increase knowledge and understanding for Dynamics 365. As an advocate for both providers and customers, I'm committed to ensure that customers constantly changing needs are meet, and I see community as key for increasing expertise. I welcome you to connect with me.

4 comments on “AX2012 : Use queries as criteria

  1. Greetings,

    Thanks for you post which helped me understand about the Criteria.

    I have small issue which i am facing with multiple days
    Here i am storing the range of criteria in Container Field in one form

    when i am trying the retrieve that range in another form using that table(TestTable)
    i am getting error at this point

    querybuilddatasource = new Query(TestTable.ContainerField);

    I am getting error as Bad Container, if you have any idea regarding this please help me.

    Like

  2. Microsoft Dynamics AX is an adaptable business management solution that enables companies and their workers to make business decisions with greater confidence.
    Please share on :- Dynamics ax consulting

    Like

  3. Pingback: Master data synchronization using ColumbusSync - Warehouse Management and Distribution - Microsoft Dynamics AX - Microsoft Dynamics Community

  4. Pingback: Master data synchronization using ColumbusSync | Kurt Hatlevik – Dynamics Ax Blog

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: