The Document Delivery Mgt. codeunit is used to submit records for Clever Document Delivery to process. Key values that determine how the records are handled can be set with various Set functions before calling the SubmitRecords function.
Example 1
The simplest example is just to create a record ref that is filtered to the record(s) to submit and call SubmitRecords:
var
SalesInvoiceHeader: Record "Sales Invoice Header";
RecRef: RecordRef;
DocDelMgt: Codeunit "Document Delivery Mgt. CDDTMN";
begin
//find the last sales invoice header and submit to Clever Document Delivery
SalesInvoiceHeader.FindLast();
SalesInvoiceHeader.SetRecFilter();
RecRef.GetTable(SalesInvoiceHeader);
DocDelMgt.SubmitRecords(RecRef);
end;
The following Set functions can be called to alter the behaviour of the SubmitRecords function.
SetProcessType
ProcessType determines whether the email is sent or queue (equivalent to the "Send Email" and "Queue Email" actions on pages). Set this to: - 1 = Send email - 2 = Queue email i.e. calculate the Document Log record(s) to be processed by the job queue later
SetBatchType
BatchType determines whether an email is created per record or a single email is created for all records: - 0 = One document per record - 1 = One document for all records - 2 = Prompt the user for selection
SetBatchSendBehaviour
BatchSendBehaviour determines whether a seperate attachment is create for each record or a single attachment for all records. - 0 = separate attachment for each record - 1 = one attachment for all records
SetDocumentType
DocumentType determines the Document Type that will be used to process the records. If this is left blank Clever Document Delivery will filter the Document Types by the Primary Table No. Filter (the tables that the document type is designed to work with).
If only a single document type can be used with the records that have been submitted, or the document type has been specified with SetDocumentType, that document type will be used. Otherwise the user will prompted to select the document type that they want to use.
SetCustomLayout
Determines the custom report layout to use for the records that have been submitted.
This function takes both an integer and a text parameter. The integer is for older versions of Microsoft Dynamics NAV where the primary key of the custom layout table was an integer. In Microsoft Dynamics Business Central the text parameter should be used and should match an existing Custom Report Layout code.
SetReferenceNo
A ReferenceNo can be set when invoking Clever Document Delivery. This will be passed to the Reference No. field of the Document Log records. This field is not used by Clever Document Delivery but can be used by another app to record log entries and link them to other records.