Yes, you can use MODIFY(FALSE); instead of MODIFY(TRUE);
If you want to do it in a form, you need to put some code in the "Form - OnModifyRecord()"-trigger:
MODIFY(FALSE); // you write the record yourself, without using the triggers
EXIT(FALSE); // you tell Navision NOT to modify the record (you just did it yourself)
Regards,Alain Krikilion No PM,please use the forum. || May the <SOLVED>-attribute be in your title!
Check the Rec.MyField value against the xrec.MyField value in the on modify trigger, if the code is in a code unit then there is no xrec so store the original record and compare the field to the changed record.
OnModify()
// Test the primary key fields match and if changed
IF (rec."No." <> xrec."No.") OR (rec.MyField = xrec.MyField)THEN
EXIT;
Why not just create a limited entry new form for the users you want to lock out of changing these fields, make this the default and the original form run from setup?
Which still saves the record, it just skips the rest of the OnModify code. If you want to prevent the record from being saved, you do ERROR instead of EXIT.
Ok then on after get record, store the record in a variable, on modify check the field against the variable, if the field has changed update and modify the variable, and EXIT(FALSE) the OnModify form trigger
Form - OnAfterGetRecord()
OldRec.GET("No.");
Form - OnModifyRecord() : Boolean
IF OldRec.MyField <> MyField THEN BEGIN
OldRec.MyField := MyField; // Update only the one field
OldRec.MODIFY;
END;
Rec := Oldrec;
EXIT(FALSE); // This is all you need not to commit the changes
Comments
If you want to do it in a form, you need to put some code in the "Form - OnModifyRecord()"-trigger:
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
RIS Plus, LLC
OnModify()
// Test the primary key fields match and if changed
IF (rec."No." <> xrec."No.") OR (rec.MyField = xrec.MyField)THEN
EXIT;
Why not just create a limited entry new form for the users you want to lock out of changing these fields, make this the default and the original form run from setup?
Mobile: +44(0)7854 842801
Email: david.cox@adeptris.com
Twitter: https://twitter.com/Adeptris
Website: http://www.adeptris.com
RIS Plus, LLC
Form - OnAfterGetRecord()
OldRec.GET("No.");
Form - OnModifyRecord() : Boolean
IF OldRec.MyField <> MyField THEN BEGIN
OldRec.MyField := MyField; // Update only the one field
OldRec.MODIFY;
END;
Rec := Oldrec;
EXIT(FALSE); // This is all you need not to commit the changes
Mobile: +44(0)7854 842801
Email: david.cox@adeptris.com
Twitter: https://twitter.com/Adeptris
Website: http://www.adeptris.com