Search Results for

    Show / Hide Table of Contents

    Email Invoice Job

    This page documents the posted sales invoice email job implemented by codeunit 73053601 lts_opsaEmailInvoice.

    Purpose

    The job sends posted sales invoices to customers by email with a PDF attachment generated from Report Selections for S.Invoice.

    Object And Entry Points

    • AL object: codeunit 73053601 lts_opsaEmailInvoice
    • Main runner: OnRun calls Process on lts_opsaEntry
    • Waiting entry creation: InsertWaitingEntry(InvoiceNo)
    • Email sender: EmailInvoice(SalesInvoice, ToEmails)

    Prerequisites

    • App setting Enable Email Invoice Job is enabled.
    • At least one active Operations Automation Setup exists for:
      • Object Type to Run = Codeunit
      • Object ID to Run = lts_opsaEmailInvoice
      • Blocked = false
    • Customer email address exists (resolved by lts_opsaEMail.GetCustomerEmailAddress).
    • Report Selections for S.Invoice is configured.
    • If needed, a Custom Report Selection layout is configured for the customer.

    How Waiting Entries Are Created

    InsertWaitingEntry(InvoiceNo) performs the following:

    1. Reads the posted sales invoice record.
    2. Verifies the feature flag Enable Email Invoice Job.
    3. Finds matching setup records for this codeunit.
    4. Applies setup record filters through GetRecordTableFilterValue and Sales Invoice Header No.
    5. Prevents duplicate waiting entries for the same setup and source record unless AllowReEntry(true) is used.
    6. Creates a new entry with:
      • Description: To email invoice: {Invoice No.}
      • Source document type: Sales Invoice
      • Status: Waiting

    Processing Flow

    When the entry runs:

    1. Process resolves Source Record ID to Sales Invoice Header.
    2. EmailInvoice builds email details:
      • Subject: Customer {Bill-to Customer No.}: Please find your invoice {Invoice No.}
      • Body: HTML generated from selected report and layout; falls back to subject text.
      • Attachment: PDF rendered from selected invoice report.
      • Filename: {InvoiceNo}_invoice.pdf
    3. Email is sent through lts_opsaEMail.SendEmail.
    4. A success log is created: Invoice emailed: {ToEmails}.

    Filtering Behavior

    Setup-level record filters are evaluated against Sales Invoice Header and invoice No. Only invoices included by setup filters generate waiting entries.

    Logging

    • Success log status: Success
    • Log message format: Invoice emailed: {email list}

    Common Failure Points

    • To email address is blank for the bill-to customer.
    • Report selection for S.Invoice is not configured.
    • Custom report layout configuration is invalid.
    • Email scenario or sending account is not configured in Business Central.

    Related Pages

    • How-to
    • Troubleshooting
    • Concepts
    • Edit this page
    In this article
    Back to top Lonicera