Announcements
Hello,
I am trying to create a report to batch post warehouse shipments withing NAV 2018. I have it working calling the posting codeunit, however, it has a pop up message for every record that would be reported. i.e selected ship or ship and invoice, and also, the confirmation that the document posted. How can i code into a report to handle these with predetermined values? I know its been done elsewhere in the system but I could not figure it out.
Please do not suggest the other dev forums, cause I cant ask a question on there.
Thanks,
-Chaz Kim
This is it! except I didnt have to use the validation portion, in the report i pass a variable if I want to invoice, so then used that for the value in WhsePostShipment.SetPostingSettings which still allows the user flexability.
Thanks!
Hi, yes exactly - use codeunit 5763 instead, if you want to bypass the manual input. Also notice that on record 7321 there is a function that looks like it turns off Dialogs. So you can try with something like this (not tested here):
OnRun()
WarehouseShipmentLine.SetHideValidationDialog(TRUE);
WhsePostShipment.SetPostingSettings(TRUE);
WhsePostShipment.RUN(WarehouseShipmentLine);
variables:
Name DataType Subtype Length
WarehouseShipmentLine Record Warehouse Shipment Line
WhsePostShipment Codeunit Whse.-Post Shipment
this kind of simulates the code from codeunit 5764, but instead of asking user if they want to Invoice, you make that choice in your own code. I hope this gets you one step further,
Hello,
thanks for the response, I am trying to do warehouse shipment batch posting so it would be codeunit
Hi Chaz,
For sales posting, you could call codeunit 80.RUN (not 81 which is the one called in the UI). And call it with a SalesHeader record, which you first mark with post and / or ship - something like this, done for each record in a loop:
SalesHeader.Ship := TRUE;
SalesHeader.Invoice := TRUE;
SalesPost.RUN(SalesHeader); //SalesPost = Codeunit 80
Note that on codeunit 80 there are a number of other functions like SetPreviewMode and SetSuppressCommit, that you can call before the posting. These functions take a paramater and store it in a global variable, so if you need to exten this you could add a function to codeunit 80 called "SetShowDialog", and call that. Then amend the code so instead of for example:
MESSAGE('Posting completed.');
to
IF NOT ShowDialog THEN
MESSAGE('Posting Completed.');
I hope you see what I mean?
André Arnaud de Cal... 291,359 Super User 2024 Season 2
Martin Dráb 230,370 Most Valuable Professional
nmaenpaa 101,156