NAV2016 Use temporary data in SubForm

doddwelldoddwell 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.

Comments

  • KishormKishorm Member Posts: 921
    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.
  • doddwelldoddwell Member Posts: 65
    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.
Sign In or Register to comment.