---
id: guideline/microsoft/knowledge/events/register-workflow-libraries-through-extension-points
type: guideline
title: Register custom workflow library entries through their extension points
summary: Business Central rebuilds the workflow event, response, and table relation libraries during an upgrade. Custom entries added only during installation can initially appear in the workflow editor but disappear when those libraries are recreated.
tier: official
language: en
tags:
  - workflow
  - workflow-event
  - workflow-response
  - workflow-library
  - workflow-registration
  - upgrade
  - subscriber
  - onaddworkfloweventstolibrary
system: development
review:
  state: derived
  by: null
  at: null
  flags: []
generated:
  at: "2026-12-02T00:15:44.908Z"
  pipeline: 0.2.0
  prompts: {}
  input_hash: 6f56ecd3ce48e9cb5d1935c910928305d217bc76
evidence:
  - kind: guideline
    url: https://github.com/microsoft/BCQuality/blob/main/microsoft/knowledge/events/register-workflow-libraries-through-extension-points.md
    title: "microsoft/BCQuality: Register custom workflow library entries through their extension points"
    date: "2026-11-30"
    commit: 863acaa2bcbd27d73e72d02527c65c8dc5af5d01
    t: null
    quote: null
links:
  learn: []
  objects: []
  features: []
  topics: []
  localizations: []
  videos: []
  posts: []
  guidelines: []
  changes:
    - change/bcquality/289
  related:
    - to: object/codeunit/1520
      title: codeunit 1520 "Workflow Event Handling"
      label: possibly related
      why: a code span in the rule names it
      by: code
repo_path: microsoft/knowledge/events/register-workflow-libraries-through-extension-points.md
layer: microsoft
kind: rule
domain: events
bc_version:
  - all
technologies:
  - al
countries:
  - w1
application_area:
  - all
examples: 2
identifiers:
  - OnAddWorkflowEventsToLibrary
  - AddEventToLibrary
  - AddResponsePredecessor
  - OnAddWorkflowResponsesToLibrary
  - AddResponseToLibrary
  - OnAddWorkflowResponsePredecessorsToLibrary
---

# Register custom workflow library entries through their extension points

> Business Central rebuilds the workflow event, response, and table relation libraries during an upgrade. Custom entries added only during installation can initially appear in the workflow editor but disappear when those libraries are recreated.

[Rule on GitHub](https://github.com/microsoft/BCQuality/blob/main/microsoft/knowledge/events/register-workflow-libraries-through-extension-points.md) · microsoft layer · events · BC all · tier official · derived

## Description

Business Central rebuilds the workflow event, response, and table relation libraries during an upgrade. Custom entries added only during installation can initially appear in the workflow editor but disappear when those libraries are recreated. The compiler cannot tell that the registration will be lost.

## Best Practice

Register each custom workflow event, response, or table relation through the corresponding workflow library extension point, so the framework can recreate it when the library is rebuilt. For example, subscribe to `OnAddWorkflowEventsToLibrary` in `Workflow Event Handling` and call `AddEventToLibrary` for the custom event. Register only the entries the extension adds; an existing standard response does not need a new custom response.

When pairing a custom event with an existing standard response, register the combination with `AddResponsePredecessor` from `OnAddWorkflowResponsesToLibrary`. In BC 28, `AddResponseToLibrary` exits if the response already exists, so its `OnAddWorkflowResponsePredecessorsToLibrary` callback may not run for that response in an existing company. The sample registers the combination independently of that callback.

The sample uses namespaces from BC 23 and later; remove its `using` directives when adapting it to earlier releases. It illustrates library registration, not the code that raises the workflow event or configures an approval workflow.

See sample: [`register-workflow-libraries-through-extension-points.good.al`](https://github.com/microsoft/BCQuality/blob/main/microsoft/knowledge/events/register-workflow-libraries-through-extension-points.good.al).

## Anti Pattern

Adding a custom workflow library entry once from an install trigger without registering that same entry through the appropriate library extension point. The entry may work until an upgrade recreates the library, after which it is missing. Check the extension's other codeunits for a registration subscriber before reporting a missing registration; the subscriber need not be in the same file as the install trigger or the workflow handler.

Do not flag a custom workflow event merely for being custom, or require a custom response when the extension uses an existing standard response.

See sample: [`register-workflow-libraries-through-extension-points.bad.al`](https://github.com/microsoft/BCQuality/blob/main/microsoft/knowledge/events/register-workflow-libraries-through-extension-points.bad.al).

## References

- [Walkthrough: Implementing New Workflow Events and Responses](https://learn.microsoft.com/dynamics365/business-central/dev-itpro/developer/devenv-walkthrough-workflow-events-responses)
- [Workflow Response Handling codeunit](https://learn.microsoft.com/dynamics365/business-central/application/base-application/codeunit/system.automation.workflow-response-handling)
- [Namespaces in AL](https://learn.microsoft.com/dynamics365/business-central/dev-itpro/developer/devenv-namespaces-overview)

## Examples

- [Good: register-workflow-libraries-through-extension-points.good.al](https://github.com/microsoft/BCQuality/blob/main/microsoft/knowledge/events/register-workflow-libraries-through-extension-points.good.al)
- [Bad: register-workflow-libraries-through-extension-points.bad.al](https://github.com/microsoft/BCQuality/blob/main/microsoft/knowledge/events/register-workflow-libraries-through-extension-points.bad.al)

## Names

- [codeunit 1520 "Workflow Event Handling"](../../../../objects/codeunit/1520.md) (possibly related: a code span names it)

## Changed by

- [#289 workflow-library-registration](../../../../changes/bcquality/289.md), 2026-11-30

---

From microsoft/BCQuality at 863acaa, MIT License, Copyright (c) 2026 Microsoft Corporation ([license](../../../LICENSE-BCQuality.txt)).
