--- title: "Extending attachment generation: overview" slug: "bc-extending-attachment-generation-overview" description: "Extend your attachment generator in SaaS with custom processes and codeunits for Microsoft Dynamics 365 Business Central. Optimize your workflow today!" tags: ["BC", "BIS", "Business Central", "Business Integration Solutions", "Task"] updated: 2026-06-25T09:59:07Z published: 2026-06-25T09:59:07Z canonical: "docs.staedean.com/bc-extending-attachment-generation-overview" --- > ## Documentation Index > Fetch the complete documentation index at: https://docs.staedean.com/llms.txt > Use this file to discover all available pages before exploring further. # Extending attachment generation: overview > [!NOTE] > This is the SaaS version to extend the attachment generator. Please refer to [Custom Report connector](/business-central/docs/bc-custom-report-connector) for the on-premise version. 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 Microsoft Dynamics 365 Business Central AL. - Basic understanding of Business Integration Solutions. - A development license. ## 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()`. ```plaintext 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; } ``` 3. Create an enum extension that extends enum `"BIS Attachment Generator"`. 4. Add the value to display in the **Generator** field options and assign the codeunit that implements `BISIOnGenerateAttachment`. ```plaintext enumextension 50000 "Ext Attachment Generator" extends "BIS Attachment Generator" {    value(50000; ExtGenerator)    {        Caption = 'Ext Generator';        Implementation = BISIOnGenerateAttachment = "EXT Custom Generator";    } } ``` 5. **Ext Generator** now appears in the options of the **Generator** field. Select that option to run the extension function. ## 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()`. ```plaintext 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; } ``` 3. Create an enum extension that extends enum `"BIS Attachment Generator"`. 4. Add the value to display in the **Generator** field options and assign the codeunit that implements `BISIOnGenerateAttachment`. ```plaintext 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";    } } ``` 5. **Ext Process** now appears in the options of the **Pre-Attach Process** field. Select that option to run the extension function. ## Related - [Set up the Attachment generator activity](/bc-set-up-the-attachment-generator-activity.md) - [Custom Report connector](/bc-custom-report-connector.md)