Skip to content

[API] Add API - Codeunits app (sample API codeunits) - #10289

Draft
Onat Buyukakkus (onbuyuka) wants to merge 3 commits into
mainfrom
feature/api-codeunits-app
Draft

[API] Add API - Codeunits app (sample API codeunits)#10289
Onat Buyukakkus (onbuyuka) wants to merge 3 commits into
mainfrom
feature/api-codeunits-app

Conversation

@onbuyuka

@onbuyuka Onat Buyukakkus (onbuyuka) commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

What & why

Adds a new API - Codeunits app (src/Apps/W1/APICodeunits) that exposes selected standard Business Central operations as API codeunits — non-data-bound unbound actions published under the microsoft/codeunits route — for programmatic and agent (MCP) access.

This was split out of PR #10008 ([MCP] Add codeunit APIs as MCP tools) so the sample/utility app can be reviewed and shipped independently of the MCP configuration changes. The app provides the concrete API codeunits that the MCP work surfaces as tools.

The app wraps existing platform/base functionality (no new business logic); each codeunit is a thin facade:

  • Approvals API (6008) — GetDirectApprover.
  • Environment API (6010) — environment/tenant info (IsProduction, IsSandbox, IsSaaS, GetEnvironmentName, GetAadTenantId, license/trial state, start/end dates, VersionInstalled, …).
  • Identity API (6011) — user/plan checks (IsPlanAssignedToUser, IsUserTenantAdmin, ArePermissionsCustomized, IsFirstLogin, penultimate login, …).
  • Date Time API (6012) — recurrence, time zone and Unix timestamp helpers.
  • No Series API (6013) — GetNextNo, PeekNextNo, GetLastNoUsed, manual/automatic/date-order checks, SimulateGetNextNo.

Object ID range 6007–6014, target Cloud.

Following earlier review, a few low-value / hard-to-use actions were removed before this PR: Approve/Reject/Cancel on Approvals API (require an internal workflow step instance id with no discovery path) and the parameterless CreateTimestampSeconds()/CreateTimestampMilliseconds() overloads on Date Time API (kept the DateTime-argument versions).

Linked work

Fixes AB#647046

Related ADO work item: AB#641822 (platform API-codeunit subtype). Companion PR: #10008.

How I validated this

  • I read the full diff and it contains only changes I intended.
  • I built the affected app(s) locally with no new analyzer warnings.
  • I ran the change in Business Central and confirmed it behaves as expected.
  • I added or updated tests for the new behavior, or explained below why none are needed.

What I tested and the outcome

Draft — local build/run validation still pending. The app was split cleanly from PR #10008 (the app files are unchanged from that branch aside from the method removals noted above). No automated tests are included yet; test coverage is a planned follow-up.

Risk & compatibility

  • Additive only — introduces a brand-new app; does not modify any existing objects, so there is no upgrade/data impact and no conflict with main.
  • Interim namespace routing — until the platform ships the API codeunit SubType (AB#641822), these codeunits are identified by the Microsoft.API.Codeunits namespace and routed as microsoft/codeunits/beta. To be revisited when the subtype is available.
  • Follow-up — automated tests to be added before ready-for-review.

New W1 app (id range 6007-6014, target Cloud) exposing selected non-data-bound Business Central operations as API codeunits under the microsoft/codeunits route. Includes five wrapper codeunits - No. Series, Approvals, Environment, Identity and Date Time - plus the objects permission set. The API subtype/publisher attributes depend on platform AB#641822 and will be added when it ships.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: eb90ebfd-967b-4ba4-98ec-57b054806669
Per review, drop API tools that add little value or cannot be used:
- Date Time API: parameterless CreateTimestampSeconds() and
  CreateTimestampMilliseconds() (kept the DateTime overloads).
- Approvals API: Approve, Reject and Cancel, which require a
  workflowStepInstanceId this toolset provides no way to discover
  (kept GetDirectApprover).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 1b34da29-3e61-4831-9999-c4e3cce5f128
@github-actions github-actions Bot added AL: Apps (W1) Add-on apps for W1 Integration GitHub request for Integration area labels Aug 17, 2026
@github-actions github-actions Bot added this to the Version 29.0 milestone Aug 17, 2026
Add the new "API - Codeunits" app (src/Apps/W1/APICodeunits) to the build
registration so it is compiled, translated and shipped like other W1 apps:
- build/projects.json: new project entry (W1 path, hasTranslations, All
  countries, base ruleset), mirroring API Reports - Finance.
- build/groups.json: group membership (AllExtensions, Financials,
  FinancialsExtensions, OnPrem, OnPremExtensions).
- build/projects/Apps <CC>/.AL-Go/settings.json (all 23 country projects):
  add the app folder to appFolders. No test entry as the app has no test
  project yet.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 1b34da29-3e61-4831-9999-c4e3cce5f128
@github-actions github-actions Bot added the Build: scripts & configs Build scripts and configuration files label Aug 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AL: Apps (W1) Add-on apps for W1 Build: scripts & configs Build scripts and configuration files Integration GitHub request for Integration area

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant