Показать сообщение отдельно
Старый 17.12.2008, 12:05   #1  
Blog bot is offline
Blog bot
Участник
 
25,643 / 848 (80) +++++++
Регистрация: 28.10.2006
axaptapedia: Validate field values on form
Источник: http://www.axaptapedia.com/Validate_...values_on_form
==============

Summary: Validating a field on a form

A nifty trick for comparing the "old" value against the "new" value using "obj.orig()" when validating a field on a form.


Example:

Change the behavior of the "Customer Group" on "CustTable" form.


Overwrite the method "validate" on the field "CustGroup" on the data source on "CustTable" form.



Original method:


X++:
public boolean validate()
{
    boolean ret;

    ret = super();

    return ret;
}
Change method:

X++:
public boolean validate()
{
    boolean ret;
    ;
    if(custTable.orig().CustGroup == '30') // Non changeable group.
    {
        info('You cannot change this Customer group');
        ret = false;
    } else {
        ret = super();
    }
    return ret;

}
Note: I've explained the general principle for validating a field against it's old value, however there are some issues with the data source not refreshing data set when changing the value back and forth.


Источник: http://www.axaptapedia.com/Validate_...values_on_form
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору.