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
-
Use Tell Me (Alt+Q) and search for Attachment Generation Templates.
-
Click + New to open the Attachment Generation Template Card.
-
Fill in the header fields:
Field Value Code COC-SHIPMENTDescription Certificate of Compliance — Sales Shipment Template Type Data Source Source Table No. Posted Sales Shipment Lines (table 111) Include Header Row Yes Enabled Yes -
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 Name | Type | Value | Purpose |
|---|---|---|---|---|
| 2 | Type | CONST | Item | Excludes comment lines, G/L Account lines, and other non-item line types. Only lines where Type = "Item" are included. |
| 5700 | Item Category Code | FILTER | CHEMICAL|FOOD | Only 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 Name | Source Field No. | Source Field Name | Value Text | Notes |
|---|---|---|---|---|---|
| 10 | Company Name | Contoso Manufacturing Ltd. | Constant value — appears on every row. Not sourced from the database. | ||
| 20 | Customer Name | 86 | Sell-to Customer Name | Retrieved from the Posted Sales Shipment Line at runtime. | |
| 30 | Item No. | 6 | No. | The item number from the shipment line. | |
| 40 | Product Name | 11 | Description | The item description from the shipment line. | |
| 50 | Quantity | 15 | Quantity | The shipped quantity. | |
| 60 | Unit of Measure | 5 | Unit of Measure Code | The UoM code from the shipment line. | |
| 70 | Batch No. | Sourced via a Column Relation to the Item Tracking table — see Step 4. | |||
| 80 | Expiry Date | Sourced via a Column Relation to the Item Tracking table — see Step 4. | |||
| 90 | Compliance Statement | This shipment complies with all applicable quality and safety standards. | Constant value — a fixed compliance statement on every row. | ||
| 100 | Certificate Ref. | COC-2026-00451 | Constant 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:
- Select the Batch No. column (Column No. 70) and click the Relation Setup action.
- 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.
- 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
-
Search for Attachment Groups and create a new group:
Field Value Code SHIP-COCName Sales Shipment with COC -
Open the group via the Group Attachments action.
-
In the Attachment Generation section, add a new line:
Field Value Template Code COC-SHIPMENTFile Name COC-{No.}-{Date}Output Format PDF 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.
-
Select the Attachment Generation line for
COC-SHIPMENTand click the Runtime Filters action. -
Add a runtime filter:
Field No. Field Name Default Value 3 Document 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.
Step 7: Link the Attachment Group to a Report Selection
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:
- Open the Attachment Generation Template Card for
COC-SHIPMENT. - Click Download PDF with Filters (or Download HTML with Filters for a quick preview).
- Enter a known shipment document number when prompted.
- 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:
- The standard sales shipment document (the primary attachment).
- 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.