Skip to content

Setting up a Custom Document Layout Table

DMS by Simova can be extended with code that allows to use a different table for the custom document layouts. This is important for partners using an own masterdata level instead of customers and vendors with an own document layout table or simply a standalone own document layout table.

An event is provided that allows the usage of a different table for the document layouts. The following event should be created in an event subscriber codeunit where you set the field numbers that are the equivalent to the fields in the Business Central document layout table. The following code is an example on how to defined a custom document layout table.

AL
[EventSubscriber(ObjectType::Codeunit, 5492908, 'OnSetCustomDocumentLayoutTable', '', false, false)]
local procedure OnSetCustomDocumentLayoutTable(var ParamCustomLayoutTableBoolean: Boolean; var ParamDocumentLayoutRecordRef: RecordRef; var ParamDocumentLayoutSourceTypeFieldRef: FieldRef; var ParamDocumentLayoutReportIDFieldRef: FieldRef; var ParamDocumentLayoutSourceNoFieldRef: FieldRef; var ParamDocumentLayoutReportLayoutCodeFieldRef: FieldRef)
var
    LocalRecordSIMDMSReportLayout: Record "SIM_DMS Report Selection";
begin
    ParamDocumentLayoutRecordRef.Open(LocalRecordSIMDMSReportLayout.RecordId.TableNo);
    ParamDocumentLayoutSourceNoFieldRef := ParamDocumentLayoutRecordRef.Field(LocalRecordSIMDMSReportLayout.FieldNo("Source No."));
    ParamDocumentLayoutReportIDFieldRef := ParamDocumentLayoutRecordRef.Field(LocalRecordSIMDMSReportLayout.FieldNo("Report ID"));
    ParamDocumentLayoutSourceTypeFieldRef := ParamDocumentLayoutRecordRef.Field(LocalRecordSIMDMSReportLayout.FieldNo("Source Type"));
    ParamDocumentLayoutReportLayoutCodeFieldRef := ParamDocumentLayoutRecordRef.Field(LocalRecordSIMDMSReportLayout.FieldNo("Custom Report Layout Code"));

    ParamCustomLayoutTableBoolean := true;
end;

The following values are the equivalent of the parameters in the Business Central document layout table.

  • The Parameter ParamDocumentLayoutRecordRef is the table of the custom document layout table
  • The Parameter ParamDocumentLayoutSourceNoFieldRef is the field which specifies the source no. in the BC standard table
  • The Parameter ParamDocumentLayoutReportIDFieldRef is the field which specifies the report id. in the BC standard table
  • The Parameter ParamDocumentLayoutSourceTypeFieldRef is the field which specifies the Source Type in the BC standard table
  • The Parameter ParamDocumentLayoutReportLayoutCodeFieldRef is the field which specifies the report layout in the BC standard table

It is also possible to define new values for the options field where you define the customer/vendor no. field in the mapping For the Document Layout Table.

In this documentation an event is provided that allows the usage of a new option value for the extension of the option value for the field "Use Report Layout from" in the mapping. It is also explained how to use the event that is provided to set the value of the Option Value.

To add a new Value to the option an enum extension must be created that would look like this:

AL
1
2
3
4
5
6
7
enumextension 5227465 "SIM_DMS Layout Source" extends "SIM_DMS Report Layout Source" //5492927 
{
    value(5227465; "Business Partner")
    {
        Caption = 'Business Partner';
    }
}
This code would add the option Business Partner to the Field Use Report Layout from. (Business Partner is an example value)

In order to use the new value that was added to the field "Use Report Layout from" a new event must be created in an event subscriber codeunit. There you define the table no. that should be filtered in the Document Layout Table that code would look like this:

AL
1
2
3
4
5
6
[EventSubscriber(ObjectType::Codeunit, 5492908, 'OnSetCustomDocumentLayoutTableFilter', '', false, false)]
    local procedure OnSetCustomDocumentLayoutTableFilter(ParamRecordSIMDMSMappingLine: Record "SIM_DMS Mapping Line"; var ParamDocumentLayoutSourceTypeFieldRef: FieldRef)
    begin
        if ParamRecordSIMDMSMappingLine."Use Report Layout from" = ParamRecordSIMDMSMappingLine."Use Report Layout from"::"Business Partner" then
            ParamDocumentLayoutSourceTypeFieldRef.SetRange(5492984);
    end;

This Code filters the used document layout table to according to the value of the needed table. In this case the document layout table will be filtered with the layouts that were defined for the table Business Partner.