CodeUnit return code

Hi, I have a problem what is very weird. I created a new CodeUnit and would like to use it as in Report 297 (Batch Post). In this report in the OnAfterGetRecord trigger there is a line such as: if SalesPost.run then … When I do that with my own function: ‘If CreateOrders.Run’ Navision gives me an error message regarding a COMMIT statement. I’m using Navision Attain 3.10. Please help. Thanks, Roelof.

Usually this message will come up if you call a Form or Report (with Request Form) modally in the middle of a write transaction. The system will not allow you to pass control out of the routine which does the updating as the system would then need to keep the locks it has until the control is returned from the form. My guess would be that your CreateOrders runs some sort of form.

Hi, Thanks for your reply. But why does it work well in Report 297? Roelof.

quote:


Originally posted by Roelof
Hi, Thanks for your reply. But why does it work well in Report 297? Roelof.


To answer this, one should know what both your calling function and called codeunit do. [;)] Anyway, report 297 updates the Sales Header in CalculateInvoiceDiscount function, COMMITs the changes and then runs codeunit 80 (SalesPost), which does all the dirty work, COMMITs its own changes and gives the control back; no lock conflict should be expected. [8D] Anna