OnModify trigger roll back

jordi79
Member Posts: 281
Hi All,
I did some coding in OnModify trigger of a table. This code will trigger an ERROR message based on certain conditions. Funny thing is, I found out that ERROR called from OnModify trigger does not trigger roll-back if the changes were done on an external table.
For example...
1) Code is written in OnModify of ITEM table to issue error message if "Description" field is not filled
2) I have written code to update an external table, when "Inventory Posting Group" is specified in Item Card. This code is written in OnValidate trigger of Item Table of "Inventory Posting Group" field
3) I created an item card record, specified "Inventory Posting Group", but did not specify "Description"
4) ERROR message from OnModify check is triggered, the changes to "Inventory Posting Group" in Item table is rolled back. but the changes to external table maintains. This change was not rolled back.
Any one can help out?
I did some coding in OnModify trigger of a table. This code will trigger an ERROR message based on certain conditions. Funny thing is, I found out that ERROR called from OnModify trigger does not trigger roll-back if the changes were done on an external table.
For example...
1) Code is written in OnModify of ITEM table to issue error message if "Description" field is not filled
2) I have written code to update an external table, when "Inventory Posting Group" is specified in Item Card. This code is written in OnValidate trigger of Item Table of "Inventory Posting Group" field
3) I created an item card record, specified "Inventory Posting Group", but did not specify "Description"
4) ERROR message from OnModify check is triggered, the changes to "Inventory Posting Group" in Item table is rolled back. but the changes to external table maintains. This change was not rolled back.
Any one can help out?
0
Comments
-
-
The OnValidate is called in separate transaction! It is why in many posts is written "do not change another table from OnValidate trigger". Do not forget, transaction flow is:
1) User create record (OnNewRecord etc. on form is triggered)
2) User enter value - OnValidate is called and when finishes, there is implicit commit=end of transaction...
3) After user leave the record or move to another etc. the OnInsert or OnModify is called and when finishes, there is implicit commit.
If you call Validate from code, it will be processed under one transaction with rest of your code, but when called from form by user data input, it is separate transaction...0 -
then I would say that, it is a definite NO NO to put an ERROR message in OnModify trigger...0
-
jordi79 wrote:then I would say that, it is a definite NO NO to put an ERROR message in OnModify trigger...0
-
Hi Kine,
Yes. then that would work. Actually, I have written some functions to make certain fields mandatory based on a setup table. And this code will call ERROR() from GLOBALINSERT and GLOBALMODIFY. This feature will apply to all tables in NAV.
So to make this work, I would then have to modify all validations from OnValidate to OnModify. Seems unrealistic. I guess, it will be back to drawing board.
Thanks anyway.0 -
That's why something like "mandatory" fields are better solved by another way as described in many posts about mandatory fields.0
-
kine wrote:That's why something like "mandatory" fields are better solved by another way as described in many posts about mandatory fields.
Yeah but you know that until they try it for themselves and after some months and a lot of user complaints they wont listen. ](*,)David Singleton0
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
- 322 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