Hi All!
Can you please advice how to change/remove code from default codeunit .
let say for my example if i want to remove invoice and ship from codeunit 81 "Sales-Post (Yes/No)" !
Can you please advice how to achieve this from AL ? (Business central)
Answers
Or read the code in C/Side
VAR SalesHeader : Record "Sales Header" <= Set SalesHeader.Ship := TRUE and SalesHeader.Invoice := TRUE;
VAR HideDialog : Boolean <= Set HideDialog := TRUE;
VAR IsHandled : Boolean <= Set IsHandled := TRUE;
Even if I add this parametres I still have the same dialog
I know that I should modify OnBeforeConfirmSalesPost event on Codeunit 81, but I don't know how I can do it .
can you please advice me?
the solution is created eventsubscriber .
I try to create it but I don't know how can I acces to function on standard codeunit and modify it .
I wanna to remove option ship and invoice
if you have any idea would you help me .
thnx
LOCAL Code(VAR SalesHeader : Record "Sales Header";PostAndSend : Boolean)
HideDialog := FALSE;
IsHandled := FALSE;
DefaultOption := 3;
IF IsHandled THEN
EXIT;
IF NOT HideDialog THEN
IF NOT ConfirmPost(SalesHeader,DefaultOption) THEN
EXIT;
SalesSetup.GET;
IF SalesSetup."Post with Job Queue" AND NOT PostAndSend THEN
SalesPostViaJobQueue.EnqueueSalesDoc(SalesHeader)
ELSE
CODEUNIT.RUN(CODEUNIT::"Sales-Post",SalesHeader);
LOCAL ConfirmPost(VAR SalesHeader : Record "Sales Header";DefaultOption : Integer) : Boolean
IF DefaultOption > 3 THEN
DefaultOption := 3;
IF DefaultOption <= 0 THEN
DefaultOption := 1;
WITH SalesHeader DO BEGIN
CASE "Document Type" OF
"Document Type"::Order:
BEGIN
Selection := STRMENU(ShipInvoiceQst,DefaultOption);
Ship := Selection IN [1,3];
Invoice := Selection IN [2,3];
IF Selection = 0 THEN
EXIT(FALSE);
END;
"Document Type"::"Return Order":
BEGIN
Selection := STRMENU(ReceiveInvoiceQst,DefaultOption);
IF Selection = 0 THEN
EXIT(FALSE);
Receive := Selection IN [1,3];
Invoice := Selection IN [2,3];
END
ELSE
IF NOT ConfirmManagement.ConfirmProcess(
STRSUBSTNO(PostConfirmQst,LOWERCASE(FORMAT("Document Type"))),TRUE)
THEN
EXIT(FALSE);
END;
"Print Posted Documents" := FALSE;
END;
EXIT(TRUE);
All as VAR ofcourse.
If you run it with HideDialog := true, no dialog wil appear.
You cannot change the appearance of dialog with this.
So, set Ishandled to true, and write own code. This is the only way to change appearance.
I try the code that you write me,
this is result ,
it showed two dialog box.
it's possible hide the dialog box that contain (ship invoice ship and invoice)??
best regards
It should be
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!
But I don't understand why it does work even if the functions doesn't have the same name as codeunit 81(standard) (ConfirmPost;MyConfirmPost)