Problem caused by using keyword as object name in Dynamics AX

Hello Readers,

When creating objects in Dynamics AX, it is advisable to use names which are not any keywords in Dynamics AX. Otherwise, you can end up with unexpected behavior.

A list of all keywords in Dynamics AX 2012 can be found here.

I discovered one such issue in standrd Dynamics AX.

Take a look at the table InventBuyerGroup. It has two fields named Group & Description.

Now suppose if I want to select the field Group from the table using a select statement, how will I do it?
InventBuyerGroup inventBuyerGroup;

select group from inventBuyerGroup;
Simple, So what is the catch you may ask? Well, the above statement will not compile and give an error. That is because the field name group is also a keyword in Dynamics AX. So, the compiler gets confused and cant understand that it is the field name that we are trying to refer here.

I'm not aware of any way of getting this work. Of course, there are workarounds like using a map but is that really needed? We can avoid a whole lot of this by just ensuring that we dont end up using any Dynamics AX keywords as object names.

Thats all for today. Check back soon for more.

P.S. By the way, does anyone know how we can get the above select statement to work? Don't lose too much sleep on it though... :)

Comments

Jan B. Kjeldsen said…
Well, you could use a query instead.
Zubair Ahmed said…
Hi Jan,

Yes, a query is one of the alternative. You can also use a an AOT map to map the field and use it.

Popular posts from this blog

How to add empty ranges in query

Get selected records in Dynamics AX 2012

The field with ID '0' does not exist in table - Cause and resolution.