In case the function CurrForm.UPDATE is called within the OnNewRecord Trigger of a form, navision crashes with the message "Internal Error 101 in module 60".
The reason why I need to use this call is that I want to implement a mandatory field check for several forms. I read some suggestions on the web to add some code to the OnQueryCloseForm and OnAfterGetCurrRecord trigger of the form - see code snippets below - this workes fine, but there is still a way to bypass the mandatory field check:
The user enters data on the form and does not fill out some mandatory fields. Then he creates a new record by pressing F3 - the new record is shown and the mandatory field check was not performed for the currently entered data.
So I wanted to add code to the OnNewRecord trigger including the CurrForm.UPDATE call ...
Has anybody an idea how to bypass this problem? Is this bug corrected within a newer navision version?
Relevant Code:
[Form - OnOpenForm()
OriginalRecord := Rec;
PreventMandatoryCheck := TRUE;
Form - OnAfterGetCurrRecord()
MandatoryCheckNextRecord;
Form - OnNewRecord(BelowxRec : Boolean)
MandatoryCheckNewRecord;
MandatoryCheckNextRecord()
IF PreventMandatoryCheck THEN BEGIN
PreventMandatoryCheck := FALSE;
EXIT;
END;
// check for unchanged or new record by checking primary key field(s)
IF ("No." = xRec."No.") OR ("No." = '') THEN
EXIT;
RecRef.GETTABLE(xRec);
IF NOT MandatoryFieldsFunctions.CheckMandatoryFieldError(RecRef, '', FALSE, ErrorText) THEN BEGIN
Rec := xRec;
xRec.TRANSFERFIELDS(Rec);
PreventMandatoryCheck := TRUE;
CurrForm.UPDATE(FALSE);
MESSAGE(ErrorText);
EXIT;
END
ELSE
OriginalRecord := Rec;
MandatoryCheckNewRecord()
RecRef.GETTABLE(xRec);
IF NOT MandatoryFieldsFunctions.CheckMandatoryFieldError(RecRef, '', FALSE, ErrorText) THEN BEGIN
PreventMandatoryCheck := TRUE;
Rec := xRec;
xRec.TRANSFERFIELDS(Rec);
CurrForm.UPDATE(FALSE);
MESSAGE(ErrorText);
EXIT;
END
ELSE
OriginalRecord := Rec;
PS: I know that the CurrForm.UPDATE call causes the crash - I created a new form containing only this call in the OnNewRecord trigger and pressed F3 ...
Comments
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!