---
id: change/bcquality/145
type: change
title: "#145 Process Context via manual event subscriber pattern"
summary: Adds community knowledge article documenting how to expose process context to extensions using manual event subscriber bindings tied to variable scope instead of singleton flags that persist across failed transactions.
tier: official
language: en
tags:
  - feature
  - main
system: development
review:
  state: reviewed
  by: opus
  at: "2026-10-08T02:06:37.215Z"
  flags: []
generated:
  at: "2026-10-08T01:26:53.141Z"
  pipeline: 0.2.0
  prompts:
    extract-change: 1
  input_hash: 7a41d25bbd2df541d38ec2ab84a8fc0c8f06a3b2
evidence:
  - kind: code
    url: https://github.com/microsoft/BCQuality/pull/145
    title: "microsoft/BCQuality#145: Process Context via manual event subscriber pattern"
    date: "2026-09-02"
    commit: 7a41d25bbd2df541d38ec2ab84a8fc0c8f06a3b2
    t: null
    quote: "A manual binding is the safe carrier: its lifetime is tied to a variable's scope"
links:
  learn: []
  objects: []
  features: []
  topics: []
  localizations: []
  videos: []
  posts: []
  guidelines: []
  changes: []
number: 145
repo: microsoft/BCQuality
source_id: bcquality-prs
url: https://github.com/microsoft/BCQuality/pull/145
kind: pr
base_branch: main
major: null
merged_at: "2026-09-02T12:58:59Z"
author: pri-kise
author_type: User
community_contribution: false
labels: []
change_class: code
change_kind: feature
behavior_change: false
breaking: false
files:
  count: 3
  additions: 182
  deletions: 0
  al: 3
apps: []
objects_touched: []
objects_unjoined:
  - path: community/knowledge/events/expose-process-context-via-manually-bound-flag.bad.al
    status: added
    reason: not-in-snapshot
  - path: community/knowledge/events/expose-process-context-via-manually-bound-flag.good.al
    status: added
    reason: not-in-snapshot
  - path: community/knowledge/events/expose-process-context-via-manually-bound-flag.md
    status: added
    reason: not-in-snapshot
obsoletions: []
backports: []
fixes_issues: []
work_items: []
systems:
  - development
quote: "A manual binding is the safe carrier: its lifetime is tied to a variable's scope"
joined_against:
  major: null
  commit: null
---

# #145 Process Context via manual event subscriber pattern

> Adds community knowledge article documenting how to expose process context to extensions using manual event subscriber bindings tied to variable scope instead of singleton flags that persist across failed transactions.

[Pull request](https://github.com/microsoft/BCQuality/pull/145) · merged into `main` on 2026-09-02 by pri-kise · 3 files (+182 -0), 3 AL · feature · tier official · reviewed (checked by Opus)

## What changed

- A SingleInstance boolean is unsafe because it sits outside the transaction and stays true after a failed run
- Recommended shape: a public query procedure backed by a local InternalEvent
- The event is answered by an internal flag codeunit with manual subscriber instance, bound only for the run
- Binding lifetime follows variable scope, so an error unwinds it; BindSubscription without UnbindSubscription is intended
- Includes good and bad samples; inspired by the ZUGFeRD and PEPPOL DE context logic

## AL objects touched

- `community/knowledge/events/expose-process-context-via-manually-bound-flag.bad.al`: added, not in the BC? snapshot yet
- `community/knowledge/events/expose-process-context-via-manually-bound-flag.good.al`: added, not in the BC? snapshot yet
- `community/knowledge/events/expose-process-context-via-manually-bound-flag.md`: added, not in the BC? snapshot yet

## Context

- Systems: development
- From the description: "A manual binding is the safe carrier: its lifetime is tied to a variable's scope"

Source: metadata of a merged pull request in microsoft/BCQuality (bcquality): title, labels, changed paths and counts, with a summary in our words. No source text and no description beyond one short quote (D10, D61).
