NAV2016 Use temporary data in SubForm

doddwell
Member Posts: 65
Hello
I am migrating a Form "Repayment Card" with Subform "subfrmRepaymentSchedule" from NAV4.1 to NAV2016. The subform data is based upon a Temporary Table "tmpPaymentForecast". I am getting an error:
"A transaction must be started before changes can be made to the database". When I debug the code, the error occurs on this line:
PaymentForecast..DELETEALL;
The Page/Sub Page is relationship is similar to this post:
mibuso.com/howtos/how-to-use-temporary-table-data-on-a-subform
Page - Repayment Card OnAfterGetRecord:
CurrPage.subfrmRepaymentSchedule.PAGE.GetSchedule(Rec);
Page - subfrmRepaymentSchedule:
Global Function: GetSchedule(Repayment);
Calls a Global function in a code unit:
ScheduleCalcs.BuildRepaymentSchedule(Repayment,tmpPaymentForecast);
CodeUnit ScheduleCalcs:
BuildRepaymentSchedule(VAR Repayment : Record "Repayment Plan";VAR PaymentForecastInput : Record "Payment Forecast")
//Assign the PaymentForecastInput Record to the local variable PaymentForecast
PaymentForecast.RESET;
PaymentForecast := SettlementPlanScheduleIn;
IF PaymentForecastInput.HASFILTER THEN
PaymentForecast.COPYFILTERS(PaymentForecastInput);
IF NOT PaymentForecast.ISEMPTY THEN
PaymentForecast.DELETEALL; ****This is where my error occurs.
Is this still the best approach in NAV2016? If not, what design should I use?
If it is the still the best approach, any ideas why I might be getting the error?
Many Thanks.
I am migrating a Form "Repayment Card" with Subform "subfrmRepaymentSchedule" from NAV4.1 to NAV2016. The subform data is based upon a Temporary Table "tmpPaymentForecast". I am getting an error:
"A transaction must be started before changes can be made to the database". When I debug the code, the error occurs on this line:
PaymentForecast..DELETEALL;
The Page/Sub Page is relationship is similar to this post:
mibuso.com/howtos/how-to-use-temporary-table-data-on-a-subform
Page - Repayment Card OnAfterGetRecord:
CurrPage.subfrmRepaymentSchedule.PAGE.GetSchedule(Rec);
Page - subfrmRepaymentSchedule:
Global Function: GetSchedule(Repayment);
Calls a Global function in a code unit:
ScheduleCalcs.BuildRepaymentSchedule(Repayment,tmpPaymentForecast);
CodeUnit ScheduleCalcs:
BuildRepaymentSchedule(VAR Repayment : Record "Repayment Plan";VAR PaymentForecastInput : Record "Payment Forecast")
//Assign the PaymentForecastInput Record to the local variable PaymentForecast
PaymentForecast.RESET;
PaymentForecast := SettlementPlanScheduleIn;
IF PaymentForecastInput.HASFILTER THEN
PaymentForecast.COPYFILTERS(PaymentForecastInput);
IF NOT PaymentForecast.ISEMPTY THEN
PaymentForecast.DELETEALL; ****This is where my error occurs.
Is this still the best approach in NAV2016? If not, what design should I use?
If it is the still the best approach, any ideas why I might be getting the error?
Many Thanks.
0
Comments
-
You need to do the DELETEALL on the temporary table, I.e. PaymentForecastInput not on PaymentForecast which is not a temporary table is so is the reason you are getting the error.1
-
Hello Kishorm. That answered my question - thanks. Unfortunately, as per the other day, I can't accept the answer. I created this question from a draft...I think that's the difference. Apologies.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