Options

Run Codeunit 80 with temporary record Sales Header

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

Comments

  • Options
    JJ Member Posts: 10
    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.

    J
  • Options
    remcovanhremcovanh Member Posts: 8
    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.
  • Options
    remcovanhremcovanh Member Posts: 8
    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.
  • Options
    nasonaso Member Posts: 11
    Codeunit 80 will not roll back all changes when errors occur. There are several places in the RUN trigger where commit is called.

    Regards
Sign In or Register to comment.