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.
- microsoftlayer
- eventsdomain
- 2examples
- 1pull request
Rule on GitHub · 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.
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.
References
- Walkthrough: Implementing New Workflow Events and Responses
- Workflow Response Handling codeunit
- Namespaces in AL
Examples
- Good: register-workflow-libraries-through-extension-points.good.al
- Bad: register-workflow-libraries-through-extension-points.bad.al
Names
- codeunit 1520 “Workflow Event Handling” (possibly related: a code span names it)
Changed by
- #289 workflow-library-registration, 2026-11-30
From microsoft/BCQuality at 863acaa, MIT License, Copyright (c) 2026 Microsoft Corporation (license).