You are on page 1of 4

Revised code

1.

a. There is already find method on InventJournalName and should be used


b. Throw error will stop the process/code flow from continuing which is not how this class was
written check the code before and always do the same with your logic. In this case the _ret will
never return false
c. It is never allowed to write messages in single quotes (except for constants and data migration)
and where is the label?
d. No need to check Yes/No by default ax will do the same and you save space on writing long
lines of code that in time become difficult to read
2.

a. Always use data groups if possible for new forms (not just grids but also on tabs) and adding
multiple fields to existing form. You have to create the data group in the table and add all
fields that you need to be display in the grid. This group is usually called Overview for grid.
With this in future no form changes will be done if someone decides to add new fields in the
table, he will simply add them in the already existing group.

3.

a. Labels and Help text and other properties used on fields should be placed in the lowest level.
This way you are avoiding the BP errors since this is how AX will search a Label as well
starting from lowest level. Also when you are fixing BP errors I suggest you also follow this
order and compile object by object starting from lowest level and in the end do compile on
whole project.

b.
4.

a. You have only insert transaction no need for ttsbegin/ttscomit and there are no other
processing operation that can trow error so for a block to be need it.
b. Use always find if exists.
c. Select forupdate line is totally not need it ???? And the other issue is that that line will select
the first thing that will find in the table. So this code will not work correctly.
5.

a. Avoid adding code in table methods if there is already crated a managing class that ends with
Type. This class also controls all tables methods and new code should always be placed there.
You can use them for inserts, modify field, updates and deletes. This classes already exists for
tables PurchTable, PurchLine, SalesTable, SalesLine and other main tables.
6.

a. Parameters should be get/set


b.

7.

You might also like