0
在大多數情況下,每次更改父字段時,我重寫的驗證方法都會執行兩次。一切仍然有效,但InfoLog每次顯示雙重信息。Axapta驗證覆蓋始終執行兩次
有什麼辦法可以防止這種情況發生?
感謝
public boolean validate()
{
boolean ret;
int exlowValue;
int lowValue;
int highValue;
int exhighValue;
str errorMessage;
;
ret = super();
//Make sure a numeric value was entered
if (ABC_RegExValidator::validateMe("integer", int2str (ABC_Checks_checkExtremeLow.value())))
{
//get the form values
exlowValue = ABC_Checks_checkExtremeLow.value();
lowValue = str2int(ABC_Checks_checkLow.valueStr());
highValue = str2int(ABC_Checks_checkHigh.valueStr());
exhighValue = str2int(ABC_Checks_checkExtremeHigh.valueStr());
//Extreme Low must be 0 or less than all others
if (exlowValue != 0)
{
//A non-zero value was entered; it must be less than all other fields
if ((exlowValue >= lowValue && lowValue > 0) || (exlowValue >= highValue && highValue > 0) || (exlowValue >= exhighValue && exhighValue > 0))
{
//Return an error
ret = checkfailed(strFmt("@ABC197", int2str(exlowValue)));
}
else
{
//Not greater than any other value
//Success!
ret = true;
} //Greater than all others?
}
else
{
//No errors
ret = true;
} // 0?
}
else
{
//Regular expression failed
//Return an error
ret = checkfailed("@ABC192");
} //Regular expression
return ret;
}
使用Dynamics AX 2009中,我重寫的表單字段(stringedit,intedit,組合框等)本身,而不是數據源或表驗證事件。我在驗證例程的開頭放置了一個info()語句,如果該字段通過驗證,它將顯示一次,但如果驗證失敗,則總是顯示兩次。該代碼是相當簡單: 公共布爾驗證() { 布爾RET; ; ret = super(); 如果(..statement ..) { RET = checkfailed(strFmt( 「@ SPC197」);} 其他 { RET =真; } 返回RET;} 在 – Brad 2009-11-09 15:39:29
您的評論你提到在方法開始時你有一個info()語句,但是,info()語句不是你的代碼示例的一部分,這會讓我困惑,如果你將info()語句和checkFailed那麼這就是問題出在哪裏,checkFailed()語句也使用Infolog系統來顯示警告消除檢查失敗並簡單地使用ret = false如果這仍然不是答案,那麼你可以發佈完整的代碼示例嗎? – pointer 2009-11-09 21:28:37
該info()僅用於測試,因此未包含在我發佈的代碼中。在驗證期間不使用info(),只檢查失敗。代碼現在可用。往上看。 – Brad 2009-11-10 13:55:37