Turns event subscribers on and off dynamically using BindSubscription() and UnbindSubscription() with EventSubscriberInstance = Manual for conditional event handling. Use when disabling subscribers during batch jobs, enabling page-scoped validation, implementing feature toggles via setup, turning off event handlers for performance, or controlling dynamic event execution at runtime.
68
83%
Does it follow best practices?
Run evals on this skill
Adds up to 20 points to the overall score
View guide
Passed
No findings from the security scan
Note: Default to StaticAutomatic. Use Manual only for conditional/performance scenarios. Binding is session-specific.
codeunit <ID> "<PREFIX> <Entity> Subscribers"
{
EventSubscriberInstance = Manual;
[EventSubscriber(ObjectType::Table, Database::<SourceTable>, 'OnAfterValidateEvent', '<FieldName>', false, false)]
local procedure OnValidate<FieldName>(var Rec: Record <SourceTable>)
begin
// Your validation logic here
if StrLen(Rec.<FieldName>) < 3 then
Error('<FieldName> must be at least 3 characters');
end;
}pageextension <ID> "<PREFIX> <Entity> Card Ext" extends "<SourcePageName>"
{
var
EntitySubscribers: Codeunit "<PREFIX> <Entity> Subscribers";
trigger OnOpenPage()
begin
BindSubscription(EntitySubscribers);
end;
trigger OnClosePage()
begin
UnbindSubscription(EntitySubscribers);
end;
}procedure ProcessDocument(var SourceRecord: Record <SourceTable>)
var
AdvancedValidation: Codeunit "<PREFIX> Advanced Validation";
Setup: Record "<PREFIX> Setup";
begin
if Setup.Get() and Setup."Enable Advanced Validation" then
BindSubscription(AdvancedValidation);
Codeunit.Run(Codeunit::<ProcessingCodeunit>, SourceRecord);
// Auto-unbinds when procedure ends
end;UI subscribers bound only in pages, not in job queue codeunits:
OnOpenPage → BindSubscription(UINotifications)Binding behavior:
StaticAutomatic codeunits (runtime error)Stale metadata: Recompiling bound codeunit shows error "subscriber is stale" - only during development, not production.
⚠️ Do NOT use Manual for critical business logic that must never be missed.
52f8705
If you maintain this skill, you can claim it as your own. Once claimed, you can manage eval scenarios, bundle related skills, attach documentation or rules, and ensure cross-agent compatibility.