You cannot make any ... until a Transaction has been started
kirkostas
Member Posts: 127
I am in Sales Order form and I have created a new codeunit which do some calculations.
Both of them have as table source the Sales Header table.
I am sending Sales Order REC (which is the Sales Header table) to the codeunit, I do my calculations and I put the values in some fields in the same table.
When I return to Sales Order form, even if I press Refresh I cannot see my values.
I stopped the code on OnModify trigger of Sales Header table but it never go there. I tried to use LOCKTABLE and MODIFY inside the codeunit but I get the error 'You cannot make any changes to the database until a Transaction has been started'.
I also tried COMMIT but no luck.
Is there a way to modify my fields inside the codeunit and using refresh to see them in the form?
How can I start a transaction?
Why when I do this on a form it works?
Both of them have as table source the Sales Header table.
I am sending Sales Order REC (which is the Sales Header table) to the codeunit, I do my calculations and I put the values in some fields in the same table.
When I return to Sales Order form, even if I press Refresh I cannot see my values.
I stopped the code on OnModify trigger of Sales Header table but it never go there. I tried to use LOCKTABLE and MODIFY inside the codeunit but I get the error 'You cannot make any changes to the database until a Transaction has been started'.
I also tried COMMIT but no luck.
Is there a way to modify my fields inside the codeunit and using refresh to see them in the form?
How can I start a transaction?
Why when I do this on a form it works?
kirkostas™
0
Comments
-
At what point are you passing the Sales Header to the codeunit?
It may be that you need to save the record before passing it!
As a guide look for something that does what you want to do, send a sales header and have a modified record returned, so with that in mind, look at the call to the Release Codeunit, and how this works, this sends back the modifed record to the form.
DavidAnalyst Developer with over 17 years Navision, Contract Status - Busy
Mobile: +44(0)7854 842801
Email: david.cox@adeptris.com
Twitter: https://twitter.com/Adeptris
Website: http://www.adeptris.com0 -
I am passing Sales Header table while I am on Sales Order form.
Yes I understand that the problem is that the record is locked by the form
and I am not be able to modify it.
How can I save the record before passed it?
Let me explain what I want to do.
Sales Order has a sub form Sales Line.
So I want every time the user enter a new record in Sales Line sub form to run my codeunit which is Sales Header table, do some calculations, pass the values in my new fields, update the table and when got back to Sales Order form to see the modifications.kirkostas™0 -
Ah the problem is updating the Header from the line table, while the sub form has the focus (Active), could you explain exactly what you are trying to update, is it a running total of the lines on the header, there may be a better way of doing it?
DavidAnalyst Developer with over 17 years Navision, Contract Status - Busy
Mobile: +44(0)7854 842801
Email: david.cox@adeptris.com
Twitter: https://twitter.com/Adeptris
Website: http://www.adeptris.com0 -
Hi,
When the user is entering the data in the Sales header subform, it is not the sales header table but rather the sales line table. If you want to do some calculation based on the sales line and then update the sales header which ash got some new fields, there are various ways of acheiveing the same. But first we all need to know what exactly are you trying to update.Diptish Naskar
For any queries you can also visit my blog site: http://msnavarena.blogspot.com/0 -
I just wanted to update the Sales Header table which unfortunately was handled by the form, so finally I solved my problem by entering in Form - OnModifyRecord the EXIT(TRUE); Now the form will update the table and finish the transaction and I am able to LOCKTABLE and MODIFY any field I want.
Problem SOLVED.kirkostas™0 -
If you want to make any modification on an argument, you must pass the argument by reference. If you pass it by value, any change you make in your function will not be reflected to the passed variable.Cem Karaer @ Pargesoft
Dynamics NAV Developer since 20050 -
I don't understand what are you trying to tell me.
You are trying to tell me the EXIT(TRUE) isn't safe enough?kirkostas™0 -
What I said is a general approach. You can implement whatever you feel easy. If you want to modify a record variable in any function, you must pass it by reference. In that way you do not only pass the values stored in this variable but also the memory address of the variable. Because the function will know the memory address, it will be able change the content of the original variable.Cem Karaer @ Pargesoft
Dynamics NAV Developer since 20050
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
- 323 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
