Announcements
I am trying to write a Job Queue codeunit that will at an interval try to post sales shipment from Sales Order. I have looked into
Sales-Post (Yes/No) and Sales-Post codeunits and could not find a procedure that I can use to Post a Sales Shipment from a Sales Order document.
What codeunit is available that will assist me in passing a sales header and possibly sales line and will post a sales shipment for me? Thanks a ton for the advice!
write a function in a codeunit or write a new one:
Use Job queue to call this function
First we need to define the variables.
SalesHeader: Record "Sales Header";
SalesPost: Codeunit "Sales-Post";
Once you declare the variable, you can start writing the logic. The following code will post both the shipment and invoice.
case SalesHeader."Document Type" of
SalesHeader."Document Type"::Order:
SalesHeader.Ship := true; //false if you do not want to post shipment
SalesHeader."Document Type"::"Return Order"
SalesHeader.Receive := true; //false if you do not want to post return receipt
end;
SalesHeader.Invoice := true; //false if you do not want to post the invoice
Clear(SalesPost);
SalesPost.Run(SalesHeader);
Your question has already been answered in the D365BC Forum.
But, I will just post the answer here again for people who is looking at this NAV forum.
André Arnaud de Cal... 291,359 Super User 2024 Season 2
Martin Dráb 230,370 Most Valuable Professional
nmaenpaa 101,156