How to: CoC extension classes
How-to · Core Studio 3.0 · Verified 2026-09-01
Goal: add behavior to a stock method without touching Microsoft’s class — a chain-of-command wrapper that compiles clean on the first build.
Time: ~10 minutes · Requires: a D365 VM for the build step.
Prerequisites
- A custom model referencing the model that owns the target class (ApplicationSuite for most stock classes — see create & manage a model).
- The target class and method identified (find-references first if you’re unsure who else wraps it).
Steps
-
Find the target class in the AOT explorer; right-click it → New X++ Object → class extension.
-
Review the scaffold — the Studio generates:
[ExtensionOf(classStr(YourTargetClass))]final class YourTargetClass_Extension{public int totalQty(){int ret = next totalQty();// your behavior herereturn ret;}}The
[ExtensionOf(classStr(...))]attribute, the_Extensionnaming law, and thenext-calling stub are all generated — you fill in behavior. -
Save (Ctrl+S) — the file lands in
<root>/<Model>/<Module>/AxClass/and re-indexes immediately. -
Build the model (Ctrl+B).
EDITOR · GENERATED COC WRAPPERReal UI capture pendingxpp-coc-scaffold
Verify it worked
- First build: 0 errors / 0 warnings with no hand-fix — the wrapper’s shape is compiler-proven.
- At runtime, your code runs around the stock method (
nextchains to the rest of the pipeline — Microsoft’s and any other extensions’).
If it goes wrong
- “Class extension … must be final” — you removed
final; the attribute pair is load-bearing, restore the scaffold’s declaration exactly. - Your method never fires — signature drift: the wrapper’s signature must match the target method exactly. Re-generate from the scaffold instead of hand-typing.
Next: table extensions · event handlers.