Skip to content

Extending Document Layout Selection when Posting

Document Central can be extended with code that allows changing the document layout used during the posting process. This is accomplished by utilizing events provided by the Document Central extension. The following documentation explains how to use the events provided by the Document Central extension to modify the document layout during the posting process.

An event is provided that enables the change of document layouts based on a specific value in the record. The following event should be created in an event subscriber codeunit where the 'Values' responsible for the change of the document layout are checked. The following code is an example that would change the document layout to MS-1304-BLUESIMPLE when the Location Code of the Sales Quote is BLUE.

Event OnBeforeSetDefaultDocumentLayoutDuringPostingProcess

This Event can be used to change the used document layout during the posting process when no Custom Document Layout was configured for the Customer/Vendor. The following parameters are provided by the event:

Info

When posting/converting a document without configured custom document layouts behind the respective master data (usually customer or Vendor), only 1 report is archived in the Document Central.

Name DataType Lenght Description
ParamDocumentLayoutCode Code 20 Specifies the Document Layout that was determined by Document Central Setting up Custom Report Layouts
ParamRecordRef RecordRef Specifies the source record where the posting was executed
ParamReportNoInteger Integer Specifies the Report No of the Report
ParamLayoutChangedBoolean Boolean Specified whether the Document Layout was changed by the Event
AL
[EventSubscriber(ObjectType::Codeunit, 5492908, 'OnBeforeSetDefaultDocumentLayoutDuringPostingProcess', '', false, false)]
local procedure OnBeforeSetDefaultDocumentLayoutDuringPostingProcess_CU5492908(var ParamDocumentLayoutCode: Code[20]; ParamRecordRef: RecordRef; ParamReportNoInteger: Integer; var ParamLayoutChangedBoolean: Boolean)
var
    LocalRecordSalesHeader: Record "Sales Header";
begin
    if ParamReportNoInteger = 1304 then begin
        ParamRecordRef.SetTable(LocalRecordSalesHeader);
        if LocalRecordSalesHeader."Location Code" = 'BLUE' then begin
            ParamLayoutChangedBoolean := true;
            ParamDocumentLayoutCode := 'MS-1304-BLUESIMPLE';
        end;
    end;
end;

Event OnBeforeSetCustomDocumentLayoutDuringPostingProcess

This Event can be used change the used document layouts during the posting process when Custom Document Layout where configured for the Customer/Vendor. The following parameters are provided by the event:

Info

When posting/converting a document, all configured Custom document layouts behind the respective master data (Usally Customer or Vendor) are archived in the Document Central.

Name DataType Lenght Description
ParamDocumentLayoutCode Code 20 Specifies the Document Layout that was determined by Document Central Setting up Custom Report Layouts
ParamRecordRef RecordRef Specifies the source record where the posting was executed
ParamReportNoInteger Integer Specifies the Report No of the Report
AL
[EventSubscriber(ObjectType::Codeunit, 5492908, 'OnBeforeSetCustomDocumentLayoutDuringPostingProcess', '', false, false)]
local procedure OnBeforeSetCustomDocumentLayoutDuringPostingProcess_CU5492908(var ParamDocumentLayoutCode: Code[20]; ParamRecordRef: RecordRef; ParamReportNoInteger: Integer)
var
    LocalRecordSalesHeader: Record "Sales Header";
begin
    if ParamReportNoInteger = 1304 then begin
        ParamRecordRef.SetTable(LocalRecordSalesHeader);
        if LocalRecordSalesHeader."Location Code" = 'BLUE' then
            ParamDocumentLayoutCode := 'MS-1304-BLUESIMPLE';
    end;
end;