OnModify trigger

nt
Member Posts: 160
hi all,
can i change a record and skip the OnModify trigger?
thanks.
can i change a record and skip the OnModify trigger?
thanks.
0
Comments
-
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!0 -
thanks0
-
can i do that just for one field?0
-
No, because what you want to do if you change two fields and after that you will "save" the record? (by moving to another...)0
-
The OnModify trigger fires off when a modified record is written to the database, not for individual fields.0
-
i want only save the record if i change a fied a particulary field. all the other i dont want permit to change.0
-
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?Analyst Developer with over 17 years Navision, Contract Status - Busy
Mobile: +44(0)7854 842801
Email: david.cox@adeptris.com
Twitter: https://twitter.com/Adeptris
Website: http://www.adeptris.com0 -
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.0
-
in that way all the editable fields can be modify.0
-
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 changesAnalyst Developer with over 17 years Navision, Contract Status - Busy
Mobile: +44(0)7854 842801
Email: david.cox@adeptris.com
Twitter: https://twitter.com/Adeptris
Website: http://www.adeptris.com0 -
ok thanks for all.0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions