When I was translating Navision into Italian language in 1997 I made an error: I translated the message 'Item %1 is not in inventory" with "L'articolo 51 non è a magazzino". Even if you don't know Italian, this was a typing mistake (5 instead of %). I discovered it because Italian partners started to open tickets in which they didn't understand why the system was telling them that Item 51 was not in inventory. They told me: ok, it's true, Item 51 is not in inventory, simply because I don't have any Item 51 in my Item table!!
This really stupid error taught me to pay attention when using the error messages: those must be as clear as possible for the end user, otherwise the final result will be passing your time explaining to the end user how to solve problems that most of the time are really easy to understand.
In AL we have the instruction TESTFIELD(<FieldName>,<Value>) that is really fantastic from the developer's point of view: it tests the value of one field, gives an error message to the user and makes rollback of a transaction. So with just an instruction we can make three different things!
The point is that the message you get is always the same. The only thing it changes is the name of the field specified in the instruction itself. So the result can be difficult to understand for the end user.
This instruction, for example, should not be used too much in the single table posting functions, because those procedures are called by the multiple table posting functions and are based on the journal table. Take a look at this example taken from Codeunit 21 - "Item Journal - Check Line"
The TESTFIELD instruction above is applied to the Location Code field of the Item Journal Line table under some conditions. The problem arises if the user is trying to post an inventory transaction starting from a table different from the Item Journal Line, because in that case, the error message will be:
"Location Code" must have a value in Item Journal Line, Journal Template Name = , Journal Batch Name = , Line No. = 0"
Even if this can be clear in any case because Location Code is a name used everywhere, the first question for an end user could be: what is the Item Journal Line? Why the system is talking about a table on which I'm not working? And what are the Journal Template Name and the Journal Batch Name? And why Line No. is 0? What does this mean?
Now you can understand why TESTFIELD instruction must not be used necessarily as a first choice and is better to spend two more minutes of your working time by using the ERROR instruction with a message to the user better than the standard one used by TESTFIELD.
Comments