Run Codeunit 80 with temporary record Sales Header

remcovanh
Member Posts: 8
Hello,
Can I run Codeunit 80 with a temporary record Sales Header as parameter.
Through an interface I insert a Sales Invoice in tabel 36 en 37. If an error occurs during the posting the Sales Invoice should be deleted. The error should be shown, but after that error the proces will end. So there is no possiblitity to delete the Sales Invoice in code.
Main question is if I insert a temporary record Sales Header and temporary record Sales Line is the temporary record Sales Line available in codeunit 80 if I run codeunit 80 with the temporary record Sales Header.
Can I run Codeunit 80 with a temporary record Sales Header as parameter.
Through an interface I insert a Sales Invoice in tabel 36 en 37. If an error occurs during the posting the Sales Invoice should be deleted. The error should be shown, but after that error the proces will end. So there is no possiblitity to delete the Sales Invoice in code.
Main question is if I insert a temporary record Sales Header and temporary record Sales Line is the temporary record Sales Line available in codeunit 80 if I run codeunit 80 with the temporary record Sales Header.
0
Comments
-
Codeunit 80 Cannot support a Temp Sales Header/Line Record.
Navision accesses Sales Line via a Sales Line record variable and therefore will never be able to get to your Temp Sales Line. Therefore it will never find the Sales Lines you put in your Temp Sales Line table.
If an error is raised during posting all changes to the database are then rolled back. So if you insert the records during the posting and an error occurs during the rest of the posting the changes (in this case your new Sales Invoice) will be rolled back and that data no longer exists.
Basically the Sales Invoice you insert will automatically be removed when an error occurs during the posting process.
Hope this answers your question.
J0 -
Thanks J for your reply.
I insert a record in tabel 36 and 37. After that I run codeunit 80.
I have to use a COMMIT before running codeunit 80 because I am in the middle of a write-transaction. If I don't do this the well known COMMIT-error occures.
So therefore the Salesheader and salesline will not be deleted.0 -
I solved the problem. I only use a COMMIT-statement when I use the returnvalue of codeunit 80. If I use codeunit80.RUN i don't use the commit. So therefor the commit rollback takes care of deleting the sales Invoice because I'm running codeunit 80 in the same proces as I insert the salesinvoice.0
-
Codeunit 80 will not roll back all changes when errors occur. There are several places in the RUN trigger where commit is called.
Regards0
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