1
votes

I'm looking for more information on how the basic data types in AX 2009 are validated, in an effort to expand that system.

We know that some kind of data validation occurs in almost all the base data types in AX, most notably the date field, because of some of the shortcuts you can do that take advantage of this: For example, if you type only the number 4 in a date field, the system automagically turns it into a date representing the 4th day of the current month and year. I am looking to find if there is any similar functionality for strings that I might be able to override or control.

Because strings apparently are not currently modified due to contents the way dates are, I want to put one in place myself. My current approach is to override the modifiedField method of a handful of tables to call a custom class, which would clean the data so it does not contain problematic characters, such as \r, \n or \t (some fields would be excluded, of course). Is there a better approach, preferably one that could be made more global?

1
The characters \r, \n or \t are automatically removed by AX. So are trailing spaces. Newlines (\n) are preserved in multi line string controls of cause. - Jan B. Kjeldsen
Not from my experience. I've actually had \r\n at the beginning of an item number before (I think someone copied/pasted the number incorrectly). We only caught it with an Export to Excel from the Item Details screen. There have been several other issues related to those 3 characters, which lead us to implement this change to the Export to Excel feature (which leads to other problems, as it turns out) - kingofzeal
I think it is data import problem. There is no way you can enter the \r character in AX. - Jan B. Kjeldsen
That is correct, you can't physically enter it from the keyboard except in memo-style textboxes. However, you can easily get it in other fields by copying/pasting the character from an alternate source (like Notepad or an Email). I have done this myself several times. - kingofzeal

1 Answers

1
votes

There are no low-level string or date overloads that can be accessed. Being able to manipulate every string on a global scale just doesn't make sense as something we would be able to access.

If that existed, the potential overhead you could introduce would be astronomical.

The way the Date assignment works, is most likely a kernel (or compiler?) operator assignment overload of the = sign to function as you described. And it only executes at variable assignment, not data validation as you suggested.