Skip to main content

Certificate of Compliance on Posted Sales Shipments


Scenario

A company needs to include a Certificate of Compliance (COC) whenever a posted sales shipment is emailed to a customer. The COC must contain shipment-specific details — Batch No., Expiry Date, customer name, product name, quantity, and unit of measure — pulled automatically from the shipment at the time of sending.

Some shipment lines should be excluded from the COC. For example, comment lines (which have no item data) should be filtered out. Additionally, compliance certification only applies to certain regulated product categories (e.g. chemicals and food products), so lines for other item categories should be excluded.

The COC should also include constant values such as the company name, a compliance statement, and a certificate reference number that do not come from the database.

Step 1: Create the Attachment Generation Template

  1. Use Tell Me (Alt+Q) and search for Attachment Generation Templates.

  2. Click + New to open the Attachment Generation Template Card.

  3. Fill in the header fields:

    FieldValue
    CodeCOC-SHIPMENT
    DescriptionCertificate of Compliance — Sales Shipment
    Template TypeData Source
    Source Table No.Posted Sales Shipment Lines (table 111)
    Include Header RowYes
    EnabledYes
  4. Optionally configure styling (e.g. Header Background Color = #2E75B6, Header Font Color = #FFFFFF, Font Family = Calibri, Arial, sans-serif).

Step 2: Configure Source Table Filters

Source Table Filters are static filters applied to the source table every time the template generates output. They narrow the dataset before any columns or runtime filters are evaluated.

In the Source Table Filters subpage on the Template Card, add filters to exclude unwanted lines:

Field No.Field NameTypeValuePurpose
2TypeCONSTItemExcludes comment lines, G/L Account lines, and other non-item line types. Only lines where Type = "Item" are included.
5700Item Category CodeFILTERCHEMICAL|FOODOnly includes lines for regulated product categories that require compliance certification.

How filters work: Each Source Table Filter adds a condition to the source table query. Records must satisfy all filter conditions to be included in the output. The CONST filter type matches an exact value. The FILTER type accepts Business Central filter expressions such as ranges (1000..2000), wildcards (*text*), or multiple values (CHEMICAL|FOOD).

In this example, the two filters work together: a shipment line must have Type = "Item" and an Item Category Code of either "CHEMICAL" or "FOOD" to appear in the COC. Any comment lines (Type = blank or " "), resource lines, or items in non-regulated categories are excluded automatically.

Tip: If you later need to add more categories, update the Item Category Code filter value (e.g. CHEMICAL|FOOD|PHARMA). The FILTER type supports any standard Business Central filter expression.

Step 3: Configure Columns

In the Columns subpage, define the data columns for the COC output:

Column No.Column NameSource Field No.Source Field NameValue TextNotes
10Company NameContoso Manufacturing Ltd.Constant value — appears on every row. Not sourced from the database.
20Customer Name86Sell-to Customer NameRetrieved from the Posted Sales Shipment Line at runtime.
30Item No.6No.The item number from the shipment line.
40Product Name11DescriptionThe item description from the shipment line.
50Quantity15QuantityThe shipped quantity.
60Unit of Measure5Unit of Measure CodeThe UoM code from the shipment line.
70Batch No.Sourced via a Column Relation to the Item Tracking table — see Step 4.
80Expiry DateSourced via a Column Relation to the Item Tracking table — see Step 4.
90Compliance StatementThis shipment complies with all applicable quality and safety standards.Constant value — a fixed compliance statement on every row.
100Certificate Ref.COC-2026-00451Constant value — a reference number that does not come from the database.

Constant values are set using the Value Text field on the column. When Value Text is populated, the same text appears in every row of the output. This is useful for company names, disclaimers, certification references, or any text that is the same regardless of the data.

Step 4: Configure Column Relations for Tracking Fields

The Batch No. and Expiry Date are not stored directly on the Posted Sales Shipment Line. They are held in a related tracking table. Use Column Relations to look up these values:

  1. Select the Batch No. column (Column No. 70) and click the Relation Setup action.
  2. On the Column Relation Setup card:
    • Set Relation Table No. to the appropriate tracking/lot information table.
    • Set Relation Display Field No. to the Batch/Lot No. field.
    • In the Join Fields subpart, map the shipment line's key fields (e.g. Document No., Line No.) to the corresponding fields on the tracking table.
  3. Repeat for the Expiry Date column (Column No. 80), setting the Relation Display Field to the Expiration Date field.

Tip: After configuring the first column relation, use the Save as Preset action to save the relation table and join field configuration as a named preset (e.g. ITEM-TRACKING). Then for the Expiry Date column, simply select the same preset from the Relation Preset Code field — only the Display Field needs to change.

Step 5: Create the Attachment Group

  1. Search for Attachment Groups and create a new group:

    FieldValue
    CodeSHIP-COC
    NameSales Shipment with COC
  2. Open the group via the Group Attachments action.

  3. In the Attachment Generation section, add a new line:

    FieldValue
    Template CodeCOC-SHIPMENT
    File NameCOC-{No.}-{Date}
    Output FormatPDF

    The {No.} token will be replaced with the shipment document number and {Date} with today's date at send time (e.g. COC-SSP00142-20260323.pdf).

Step 6: Configure Runtime Filters

Runtime Filters supply filter values at the time of sending so the generated attachment only includes data for the specific document being emailed.

  1. Select the Attachment Generation line for COC-SHIPMENT and click the Runtime Filters action.

  2. Add a runtime filter:

    Field No.Field NameDefault Value
    3Document No.{No.}

    The {No.} token resolves to the posted sales shipment's document number at send time. This ensures the COC only contains lines belonging to the shipment being emailed — not all shipment lines in the system.

Choose one of the following approaches:

Option A — Customer-specific: Open the Customer Card → Related → Document Layouts. On the Shipment usage line, set Attachment Group Code to SHIP-COC.

Option B — Global (all customers): Search for Report Selection - Sales. On the Shipment usage line, set Attachment Group Code to SHIP-COC.

Step 8: Test the Output

Before going live, verify the COC output:

  1. Open the Attachment Generation Template Card for COC-SHIPMENT.
  2. Click Download PDF with Filters (or Download HTML with Filters for a quick preview).
  3. Enter a known shipment document number when prompted.
  4. Review the output — confirm that:
    • Only item lines appear (no comments).
    • Only lines with Item Category Code of CHEMICAL or FOOD are included.
    • The constant columns (Company Name, Compliance Statement, Certificate Ref.) display on every row.
    • Batch No. and Expiry Date are populated from the tracking table.

Result

When a posted sales shipment is emailed, the customer receives:

  1. The standard sales shipment document (the primary attachment).
  2. A Certificate of Compliance PDF (COC-SSP00142-20260323.pdf) automatically generated by Elevate Attachments, containing only the regulated product lines (CHEMICAL and FOOD categories) from that specific shipment, complete with batch numbers, expiry dates, and the company's compliance statement.

No manual steps are required at send time — the COC is generated and attached automatically.