A blog offering various X++ code snippets and tips for Microsoft Dynamics AX

Friday, January 09, 2009

Getting the number of records from table name.

I replied to the following question on the forums:

How to check if a table has records in it, from its name, NOT from a buffer.

The trick is some standard AX dict classes reflection (specifically DictTable):

static void recordsExist(Args _args)
  SysDictTable dictTable;
  dictTable = new SysDictTable(tableName2Id('TableStringHere'));

  if (dictTable)
    if (dictTable.recordCount() > 0)
      info ("This table has records.");
      info ("No records");
    info ("Table does not exist");

If you any questions or comments e-mail me on: mirko@mirkobonello.com

Thursday, January 08, 2009

3rd Party Document Integration Tool

Bottom Line is a company whose website I found while I was browsing the web.

According to the site it works on both Dynamics Ax and Dynamics NAV and provides powerful document integration with a nice report designer, and a cool document integration workflow designer and other features like barcodes, cheques, integration to e-mail, fax, bank transfers etc.

I haven't tried the product but viewed the 6 minute presentation on the website. Hope to see it working in action some time.

A video about this can be found on Channel 9 right here .

Note: I am not affiliated to this company in any way.

If you any questions or comments e-mail me on: mirko@mirkobonello.com

Fixed field and Related fixed field

This is an answer I gave to a question on a forum regarding fixed field and related fixed field:

Lets say you have ClothesTable and ClothesOrders.

ClothesTable has the following fields: ClotheId, Name and CollectionTypeId

MenClothesOrder has the following fields: OrderId, ClotheId, Qty OrderId could be a number sequence and Qty entered manually by the user.

CollectionTypeId has the following elements:

0 - Men

1 - Women

2 - Children

Example 1: Related Fixed Field

On MenClothesOrder we create a new relation to ClothesTable and specify the follwing two:

1. Normal = ClotheId to ClotheId (Best practice to specify this on the EDT but you have to do it here on the table too for this to work) and

2. Related Fixed Field 0 = ClothesTable.CollecTionTypeId.

This shows that the lookup to the clothes table should show only clothes with the same ClotheId (point 1) AND clothes that are of type Men (point 2) because the our table deals with order for mens' clothes. We use 0 because Menis element 0 in the Enum.

Example 2: Fixed Field

This kinda works the other way round:

Imagine you have a ClothesOrders table (generic) and you have seperate tables for MenClothesTable, WomenClothesTable and ChildrenClothesTable. Fixed field says that the specified normal relation (on ClotheId) to MenClothesTable only works if the CollectionTypeId of the current record is set to 0 (Men) else the relation is disabled.

If you need furhter clarification do not hesitate to ask.

If you any questions or comments e-mail me on: mirko@mirkobonello.com