Business Integration Solutions SaaS

This is the SaaS version to extend attachment generator. Please refer to Custom Report Connector for the On Premise version.

Extending Attachment Generation - Overview

The attachment generator line has two fields which allow the user to alter the behavior of generating the attachment content or altering the attachment content after it is generated. These fields are Generator and Pre-Attach Process. The generator field is disabled in case of file attachments, since in this case, the file content is uploaded by the user.

There are currently two default generators.

Generator Purpose
Run Object with scope (Default) Runs the object chosen using also 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 are required

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

How To: Create a custom generator.

Usage

Use this task when you want to override the way the attachment content is generated.

Steps

  1. Create a custom codeunit which 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 be shown 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 will now appear 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 task when you want to do something with the attachment content before it is attached.

Steps

  1. Create a custom codeunit which 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 be shown 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 will now appear in the options of the Pre-Attach Process field. Select that option to run the extension function.