AXForum  
Вернуться   AXForum > Microsoft Dynamics AX > DAX Blogs
All
Забыли пароль?
Зарегистрироваться Правила Справка Пользователи Сообщения за день Поиск

 
 
Опции темы Поиск в этой теме Опции просмотра
Старый 17.11.2014, 16:11   #1  
Blog bot is offline
Blog bot
Участник
 
25,617 / 848 (80) +++++++
Регистрация: 28.10.2006
palleagermark: Thoughts on validateField
Источник: http://www.agermark.com/2014/11/thou...datefield.html
==============

Here is a couple of thoughts on how to write validateField methods in the best possible way. The validateField method is automatically called when you change a field value of a record in the client.

There are two things about validateField, that I haven't been able to figure out:
  • Is the method originally intended to be called only when a field value is changed, or should you also be able to call it to validate the current value?
  • Why do AX 2012 also have a name based validateFieldValue method?
I raise the first question because the standard AX data consistency check actually calls validateField on existing data to check the present value of the fields. That gives a number of errors from standard AX, that really isn't errors but appears so because the code on the field assumes you have modified the field value from something else to the present value.

One example of this, is the many errors you get from Currency:



In this case you could add code to see if the value actually is changed.

Also some validations should check that the field actually has value. One example from standard AX of a validation not doing this is license plate validation on warehouse locations, where a blank value in some fields will give you this error:



Here the validation looks up another location using a blank value, and the returned flag for License Plate Control will of course be blank.

Don’t update data in a validation method. You should always be able to call a validation method without risking any data to change in the system. Changes should be moved to the modifiedField, modifiedFieldValue, update or insert method.

Don't display any dialogs from the table based validation method without checking if the validation method is being triggered from a form data source. The code analysis tool on LCS will report this as a Best Practice issue, as the validation could be called from a server tier. Consider moving these dialogs to the forms where needed.




Источник: http://www.agermark.com/2014/11/thou...datefield.html
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору.
 

Похожие темы
Тема Автор Раздел Ответов Посл. сообщение
palleagermark: Team Foundation Service is now live Blog bot DAX Blogs 0 02.11.2012 17:11
palleagermark: Company Visualizer is updated Blog bot DAX Blogs 0 24.01.2012 21:11
palleagermark: Print images directly from AX without user interaction Blog bot DAX Blogs 0 04.11.2011 17:12
palleagermark: Use keyboard lookup in Product Builder enumerated fields Blog bot DAX Blogs 0 18.08.2009 23:06
Microsoft Dynamics CRM Team Blog: Thoughts on Forms Blog bot Dynamics CRM: Blogs 0 26.08.2008 00:11

Ваши права в разделе
Вы не можете создавать новые темы
Вы не можете отвечать в темах
Вы не можете прикреплять вложения
Вы не можете редактировать свои сообщения

BB коды Вкл.
Смайлы Вкл.
[IMG] код Вкл.
HTML код Выкл.
Быстрый переход

Рейтинг@Mail.ru
Часовой пояс GMT +3, время: 01:51.