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

chrisdfchrisdf Posts: 80Member
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?

Comments

  • chrisdfchrisdf Posts: 80Member
    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.
  • chrisdfchrisdf Posts: 80Member
    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?
  • hedegaardhedegaard Posts: 25Member
    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.
  • Maria-SMaria-S Posts: 62Member
    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!
Sign In or Register to comment.