Fill table in trigger OnAfterGetCurrRecord

edoderoo
Member Posts: 89
In NAV2016 I created a list page, that shows my projects. When I select a project, it will fill a second list page with some details of my project.
I created an action trigger to fill this, and this works smoothly.
Now I try to fill the same data out of the OnAfterGetCurrRecord trigger, and it shows an error stating: "A transaction should be started before changes in the database can be made". This error will *not* appear when my function does not make any changes to the data, but every delete/modify/insert will throw this error.
Is it true that you can not make changes to the database in the OnAfterGetCurrRecord trigger?
Is there a workaround?
I created an action trigger to fill this, and this works smoothly.
Now I try to fill the same data out of the OnAfterGetCurrRecord trigger, and it shows an error stating: "A transaction should be started before changes in the database can be made". This error will *not* appear when my function does not make any changes to the data, but every delete/modify/insert will throw this error.
Is it true that you can not make changes to the database in the OnAfterGetCurrRecord trigger?
Is there a workaround?
IF User.Loves('Edo') THEN ok() ELSE currReport.genSkip;
0
Best Answer
-
Correct, you cannot make database changes in that trigger.
I'm not sure of your exact requirements but is it a possibility for you to populate a temporary table and show that on the second page? If you do this then it won't give an error because you are not writing changes to the database.1
Answers
-
Correct, you cannot make database changes in that trigger.
I'm not sure of your exact requirements but is it a possibility for you to populate a temporary table and show that on the second page? If you do this then it won't give an error because you are not writing changes to the database.1 -
I will give that a try ... the name of the table is already TempSomething, and I delete all data on closing the form... but I'll try it with the temp-table property instead. Thanks for the tip!IF User.Loves('Edo') THEN ok() ELSE currReport.genSkip;0
-
Well if that's what you are doing then a Temporary table is exactly what you need.
You can set the SourceTableTemporary of the page to "Yes" and then insert records into the Rec on the page. I normally do this by having a PopulateData() function on the list page which does this and then call this function from the OnAfterGetCurrentRecord trigger of the parent page.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