Business Integration Solutions SaaS

This is the SaaS version to extend the attachment generator. Please refer to Custom Report Connector for the on-premise version.

Extending attachment generation: overview

The attachment generator line has two fields that let the user change how the attachment content is generated or modify the attachment content before it attaches. These fields are Generator and Pre-Attach Process. The Generator field is disabled for file attachments, because in that case the user uploads the file content.

Two default generators are available:

Generator Purpose
Run Object with scope (Default) Runs the object chosen using the record ID in scope as a filter.
Run Object Runs the object chosen without filtering for the record ID in scope.

The only option for Pre-Attach Process by default is None, which does nothing.

Prerequisites

The following prerequisites apply:

  • Experience developing in Business Central AL.
  • Basic understanding of Business Integration Solutions.
  • A development license.

How to: Create a custom generator

Usage

Use this activity when you want to override how the attachment content is generated.

Steps

  1. Create a custom codeunit that implements interface BISIOnGenerateAttachment.
  2. Implement the method OnGenerateAttachment().
codeunit 50000 "EXT Custom Generator" implements BISIOnGenerateAttachment
{
    procedure OnGenerateAttachment(var TempBlob: Codeunit "Temp Blob"; TempAttachmentGeneratorLine: Record "BIS Attachment Generator Line" temporary; RecID: RecordID)
    var
        TestOutStream: OutStream;
    begin
        TempBlob.CreateOutStream(TestOutStream);
        TestOutStream.WriteText('Test');
    end;
}
  1. Create an enum extension that extends enum "BIS Attachment Generator".
  2. Add the value to display in the Generator field options and assign the codeunit that implements BISIOnGenerateAttachment.
enumextension 50000 "Ext Attachment Generator" extends "BIS Attachment Generator"
{
    value(50000; ExtGenerator)
    {
        Caption = 'Ext Generator';
        Implementation = BISIOnGenerateAttachment = "EXT Custom Generator";
    }
}
  1. Ext Generator now appears in the options of the Generator field. Select that option to run the extension function.

How to: Create a custom pre-attach process

Usage

Use this activity when you want to process the attachment content before it attaches.

Steps

  1. Create a custom codeunit that implements interface BISIOnBeforeAttachToMessage.
  2. Implement the method OnBeforeAttachToMessage().
codeunit 50001 "EXT Custom Pre-Attach Process" implements BISIOnBeforeAttachToMessage
{
    procedure OnBeforeAttachToMessage(var TempBlob: Codeunit "Temp Blob"; TempAttachmentGeneratorLine: Record "BIS Attachment Generator Line" temporary; RecID: RecordID)
    var
        TestOutStream: OutStream;
    begin
        Clear(TempBlob);
        TempBlob.CreateOutStream(TestOutStream);
        TestOutStream.WriteText('Test-PreAttach');
    end;
}
  1. Create an enum extension that extends enum "BIS Attachment Generator".
  2. Add the value to display in the Generator field options and assign the codeunit that implements BISIOnGenerateAttachment.
enumextension 50001 "Ext Attach. Pre-Attach Process" extends "BIS Attachment Pre-Attach Process"
{
    value(50000; ExtProcess)
    {
        Caption = 'Ext Process';
        Implementation = BISIOnBeforeAttachToMessage = "EXT Custom Pre-Attach Process";
    }
}
  1. Ext Process now appears in the options of the Pre-Attach Process field. Select that option to run the extension function.