microsoft / microsoft/ALAppExtensions

[Event Request] codeunit 5979 "Service-Post and Send" - OnBeforConfirmPostAndSend - OnBeforePost

Open
#30,420 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

event-request ext-ready-to-implement SCM
Dominant language
AL
Stars
988
Forks
692
Avg merge
49m
Merged PRs (30d)
1

Description

Why do you need this change?

I need this change to be able to use Service post and Send for Service Header document type Order.

Describe the request
Describe the request

Hello, I was wondering if we could get two events in Codeunit 5979 "Service-Post and Send" ΓÇö OnBeforeConfirmPostAndSend and OnBeforePost?

Today the Code() procedure hard-codes the supported document types (only Invoice and Credit Memo) and calls Service-Post directly, so there is no way to support posting a Service Order from Post & Send, or to substitute the posting routine, without copying the whole codeunit. These two events would let us do that from a subscriber.

Location in the Code() procedure:

    local procedure "Code"()
    var
        TempDocumentSendingProfile: Record "Document Sending Profile" temporary;
        ServicePost: Codeunit "Service-Post";
        //>>>>>>>>>>>>>>>>>>>>>>>>>
        IsHandled: Boolean;
        SkipPost: Boolean;
        //<<<<<<<<<<<<<<<<<<<<<<<<<
    begin
        OnBeforeCode(ServiceHeader);

        //>>>>>>>>>>>>>>>>>>>>>>>>>
        IsHandled := false;
        OnBeforeConfirmPostAndSend(ServiceHeader, IsHandled);
        if IsHandled then begin
            if not ConfirmPostAndSend(ServiceHeader, TempDocumentSendingProfile) then
                exit;
        end else
        //<<<<<<<<<<<<<<<<<<<<<<<<<
            case ServiceHeader."Document Type" of
                ServiceHeader."Document Type"::Invoice,
                  ServiceHeader."Document Type"::"Credit Memo":
                    if not ConfirmPostAndSend(ServiceHeader, TempDocumentSendingProfile) then
                        exit;
                else
                    Error(NotSupportedDocumentTypeErr, ServiceHeader."Document Type");
            end;

        TempDocumentSendingProfile.CheckElectronicSendingEnabled();
        ValidateElectronicFormats(TempDocumentSendingProfile);

        //>>>>>>>>>>>>>>>>>>>>>>>>>
        IsHandled := false;
        SkipPost := false;
        OnBeforePost(ServiceHeader, IsHandled, SkipPost);
        if IsHandled then begin
            if SkipPost then
                exit;
        end else
        //<<<<<<<<<<<<<<<<<<<<<<<<<
            CODEUNIT.Run(CODEUNIT::"Service-Post", ServiceHeader);

        OnAfterPostAndBeforeSend(ServiceHeader);
        Commit();

        ServicePost.SendPostedDocumentRecord(ServiceHeader, TempDocumentSendingProfile);

        OnAfterCode(ServiceHeader);
    end;

Event publishers:

    [IntegrationEvent(false, false)]
    local procedure OnBeforeConfirmPostAndSend(var ServiceHeader: Record "Service Header"; var IsHandled: Boolean)
    begin
    end;

    [IntegrationEvent(false, false)]
    local procedure OnBeforePost(var ServiceHeader: Record "Service Header"; var IsHandled: Boolean; var SkipPost: Boolean)
    begin
    end;

With OnBeforeConfirmPostAndSend, a subscriber can accept additional document types (e.g. Order) by setting IsHandled, which runs ConfirmPostAndSend and skips the else Error. With OnBeforePost, a subscriber can replace the posting (e.g. the Ship/Consume/Invoice dialog for Orders) via IsHandled, and use SkipPost to stop before SendPostedDocumentRecord when nothing was posted.

Internal work item: AB#648196

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in Codeunit 5979 "Service-Post and Send", specifically its Code() procedure and the existing ConfirmPostAndSend and Service-Post calls. Review the requested OnBeforeConfirmPostAndSend and OnBeforePost event signatures and the document-type handling. Done means the events support the described Order and replacement-posting scenarios without copying the codeunit, with coverage for the affected behavior.

Written by the indexing model from the issue text.

Assessment

Domain
backend
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.