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 

Dynamics AX 2012 and BarTender Commander

I have previously blogged on the BarTender integration to Dynamics AX 2012.  In this blog post I want to take the integration one step further. 

Sometimes it is not possible to have a BarTender client on each machine.  Also in a Terminal Server scenario often local label printers are mapped into the RDP session, and you suddenly see that you are using up all the printer licenses you have purchased for BarTender.

image

There is a way around this, and that is to use BarTender Commander instead of the BarTender ActiveX integration. Then the printer, copies and tag values can be sent to a XML file, that the BarTender is picking up, and will automatically print out centrally.

So I needed to create some very small changes to my BarTender module to make this happen.

image

This will generate a XML file, that looks like this.

image

The BarTender commander “picks this up”.

image

And BarTender prints out accordingly.

I also see that some of the users of the BarTender integration is using it in a different way that I expected.  They are using it WITHOUT BarTender, and are just generating the XML messages.   Then they pick up this XML file, and use it for other types of integrations, like EDI and even into a dynamic document composition tools(Like StreamServ).  They then don’t need to spend a lot of time in creating SSRS reports, but more their reporting requirements into a more user-friendly reporting tool.  My comment is WOW…. I didn’t recognize that feature when I created it Smilefjes  Users are really creative and smart.  

In my last blogpost I explained how important if it is to share knowledge.  I follow up on this, and here the actual Dynamics AX 2012 source code for creating BarTender commander XML files. 

image

image

image

(Yes I know that you would prefer a “copy-paste” version, but that would be too easy Smilefjes)

Happy Daxing