NAV 2016 Upgrade Problem - A transaction must be started before changes can be made to the database.

chrisdf
Member Posts: 82
Hi,
I have a working NAV2015 solution that I have just upgraded to NAV 2016. In that solution, when the Sales Order list opens from the Role Centre there are some extra columns that involve calling code units to calculate some extra information about Group credit limits etc.
In those code units I use temporary Customer tables to do calculations. The first thing I execute is a DELETEALL statement on the temporary table.
This has worked fine in all versions from Classic to NAV2015.
In NAV2016 the page fails with a message "A transaction must be started before changes can be made to the database." Looking at the code, the sequence is as follows:
TempCust.DELETEALL
now seems to trigger new functions in Codeunit 1550 Record Restriction Management
RemoveCustomerRestrictionsBeforeDelete(VAR Rec : Record Customer;RunTrigger : Boolean)
AllowRecordUsage(Rec.RECORDID);
and then
AllowRecordUsage(RecID : RecordID)
RestrictedRecord.SETRANGE("Record ID",RecID);
RestrictedRecord.DELETEALL(TRUE);
which is where the debugger falls over with the message.
This only happens opening the page from the Role Centre. If I go to another route and open the Sales Order page from a Factbox for example it works fine.
As I said, this code has worked perfectly over the last 4/5 versions.
Anybody experienced this with NAV2106 yet?
I have a working NAV2015 solution that I have just upgraded to NAV 2016. In that solution, when the Sales Order list opens from the Role Centre there are some extra columns that involve calling code units to calculate some extra information about Group credit limits etc.
In those code units I use temporary Customer tables to do calculations. The first thing I execute is a DELETEALL statement on the temporary table.
This has worked fine in all versions from Classic to NAV2015.
In NAV2016 the page fails with a message "A transaction must be started before changes can be made to the database." Looking at the code, the sequence is as follows:
TempCust.DELETEALL
now seems to trigger new functions in Codeunit 1550 Record Restriction Management
RemoveCustomerRestrictionsBeforeDelete(VAR Rec : Record Customer;RunTrigger : Boolean)
AllowRecordUsage(Rec.RECORDID);
and then
AllowRecordUsage(RecID : RecordID)
RestrictedRecord.SETRANGE("Record ID",RecID);
RestrictedRecord.DELETEALL(TRUE);
which is where the debugger falls over with the message.
This only happens opening the page from the Role Centre. If I go to another route and open the Sales Order page from a Factbox for example it works fine.
As I said, this code has worked perfectly over the last 4/5 versions.
Anybody experienced this with NAV2106 yet?
0
Comments
-
Just a bit more refined explanation of this issue.
In a Cronus Database in NAV2016, insert the following code in the OnAfterGetNextRecord of Page 9305
//debug
Cust.GET("Sell-to Customer No.");
TempCust := Cust;
TempCust.INSERT;
TempCust.DELETEALL;
//debug
I know the code does not make sense but it illustrates the issue.
If you run the page from the development environment then you get the error mentioned above.
Anybody think this is a bug? I've even tried it on the CU1 release and no change.0 -
The workaround I found for my problem here was to modify two of the new code units.
In Code Unit 1535 - Function DeleteApprovalEntriesAfterDeleteCustomer add a line:
IF Rec.ISTEMPORARY THEN EXIT;
In Code Unit 1535 - Function DeleteApprovalCommentsAfterDeleteCustomer add a line:
IF Rec.ISTEMPORARY THEN EXIT;
In Code Unit 1550 - Function RemoveCustomerRestrictionsBeforeDelete add a line:
IF Rec.ISTEMPORARY THEN EXIT;
This is a very specific solution to my issue and I think there is a more fundamental problem underlying this new functionality - hopefully someone from Microsoft might be reading this?0 -
I think I sometimes get this error when I have put the code in the wrong trigger. E.g. on the OnReportInit instead of OnPreReport. Maybe that could be the cause. Just a thought.0
-
Hahaha, I came here with a similar question and the answer is exactly the wrong trigger. Instead of OnOpenPage I put my calculation in OnAfterGetRecord trigger of Activity page. Thanks for the hint!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