Skip to content

[Event Request] - Codeunit Report Distribution Mgt. - GetDocumentLanguageCode #29532

@auzhhv

Description

@auzhhv

Why do you need this change?

Ref #28615

procedure GetDocumentLanguageCode(DocumentVariant: Variant) LanguageCode: Code[10]
    var
        SalesInvoiceHeader: Record "Sales Invoice Header";
        SalesCrMemoHeader: Record "Sales Cr.Memo Header";
        SalesHeader: Record "Sales Header";
        PurchaseHeader: Record "Purchase Header";
        Job: Record Job;
        DocumentRecordRef: RecordRef;
        IsHandled: Boolean;
    begin
        //New Event
        IsHandled := false;
        OnBeforeGetDocumentLanguageCode(DocumentVariant, IsHandled, LanguageCode);
        if IsHandled then
            exit(LanguageCode);
        //New Event
        if DocumentVariant.IsRecord then
            DocumentRecordRef.GetTable(DocumentVariant)
        else
            if DocumentVariant.IsRecordRef then
                DocumentRecordRef := DocumentVariant;

        case DocumentRecordRef.Number of
            DATABASE::"Sales Invoice Header":
                begin
                    DocumentRecordRef.SetTable(SalesInvoiceHeader);
                    exit(SalesInvoiceHeader."Language Code");
                end;
            DATABASE::"Sales Cr.Memo Header":
                begin
                    DocumentRecordRef.SetTable(SalesCrMemoHeader);
                    exit(SalesCrMemoHeader."Language Code");
                end;
            DATABASE::"Sales Header":
                begin
                    DocumentRecordRef.SetTable(SalesHeader);
                    exit(SalesHeader."Language Code");
                end;
            DATABASE::"Purchase Header":
                begin
                    DocumentRecordRef.SetTable(PurchaseHeader);
                    exit(PurchaseHeader."Language Code");
                end;
            DATABASE::Job:
                begin
                    DocumentRecordRef.SetTable(Job);
                    exit(Job."Language Code");
                end;
            else
                OnGetDocumentLanguageCodeCaseElse(DocumentRecordRef, LanguageCode);
        end;
    end;
   [IntegrationEvent(false, false)]
    local procedure OnBeforeGetDocumentLanguageCode(DocumentRecordRef: RecordRef; var IsHandled: Boolean; var LanguageCode: Code[10])
    begin
    end;

Describe the request

We need this change to be able change the language for alle texts created by this codeunit. We want to override this for all instances where this is used because the customer always wants the texts in English. It is possible to run a copy of the codeunit on event OnAfterGetFullDocumentTypeText, but we want to avoid duplicating alle the code, with future changes in the codeunit and other extensions in mind. We only want to change the language.

Metadata

Metadata

Assignees

No one assigned

    Labels

    missing-infoThe issue misses information that prevents it from completion.

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions