views:

590

answers:

2

Is there a way, in Axapta/Dynamics Ax, to create an Extended Data Type of type integer which only allows enering values in a specified range (i.e., if the extended data type is meant for storing years, I should be able to set a range like 1900-2100), or do I have to manage the range using X++ code?

And if I need to use X++ code to manage the range, which is the best way to do it?

+1  A: 

You can can't specify the range on the extended data type itself. If the type is used for a table field, you can add code to the insert and update methods of the table, in order to validate the value whenever the record is updated. This approach could however have a cost in terms of performance.

You can also choose to just add code the the validateWrite method of the table, if you are satisfied with the validation only taking place when the value is modified from the UI.

+1  A: 

I suggest you use the ''validateField'' of the corresponding table. Search for the method in AOT\Data Dictionay\Tables to see many examples.

Jan B. Kjeldsen