Skip to content

Make usage data billing filtering extensible in SetUsageDataBillingFilters#9225

Open
miljance wants to merge 1 commit into
microsoft:mainfrom
miljance:SBSetUsageDataBillingFiltersEvent
Open

Make usage data billing filtering extensible in SetUsageDataBillingFilters#9225
miljance wants to merge 1 commit into
microsoft:mainfrom
miljance:SBSetUsageDataBillingFiltersEvent

Conversation

@miljance

@miljance miljance commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

What & why

SetUsageDataBillingFilters on table 8059 "Subscription Line" filtered "Usage Base Pricing" with a bounded SetRange from "Usage Quantity" to "Unit Cost Surcharge". That upper bound assumed enum 8007 "Usage Based Pricing" ends at "Unit Cost Surcharge", so any custom value a partner adds above it fell outside the range and was silently excluded — potentially returning an empty Usage Data Billing recordset. There was also no hook for partners to adjust the applied filters.

This change:

  • Replaces the bounded SetRange with SetFilter("Usage Base Pricing", '>=%1', Enum::"Usage Based Pricing"::"Usage Quantity"). This preserves the original behavior (still excludes "None") while remaining open-ended, so custom enum values are included instead of dropped.
  • Adds integration event OnAfterSetUsageDataBillingFilters(var UsageDataBilling; SubscriptionLine; BillingFromDate; BillingToDate) at the end of the procedure so subscribers can refine the filters without overriding the base logic.

Linked work

Fixes #9223

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

Change is a small, self-contained filter adjustment plus a new integration event publisher. The new filter >=%1 from "Usage Quantity" is logically equivalent to the previous "Usage Quantity".."Unit Cost Surcharge" range for all shipped enum values (ordinals 1–3), and additionally includes any partner-added values (ordinal ≥ 4) that the old bounded range excluded; "None" (ordinal 0) remains excluded.

Risk & compatibility

Low. For the enum values that ship today the filter result is unchanged. The only behavioral difference is that "Usage Base Pricing" values above "Unit Cost Surcharge" are now included rather than excluded — which is the intended fix. The new OnAfterSetUsageDataBillingFilters event is additive.

…lters

The local procedure SetUsageDataBillingFilters on table 8059 "Subscription
Line" filtered "Usage Base Pricing" with a bounded SetRange from
"Usage Quantity" to "Unit Cost Surcharge". That upper bound assumed the
enum 8007 "Usage Based Pricing" ended at "Unit Cost Surcharge", so any
custom values a partner adds above it were silently excluded, which could
leave the recordset empty.

- Replace the bounded SetRange with SetFilter '>=%1' from "Usage Quantity",
  which still excludes "None" but includes all current and custom values.
- Add integration event OnAfterSetUsageDataBillingFilters so subscribers
  can refine the applied filters without overriding the base logic.

Fixes microsoft#9223

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@miljance miljance requested a review from a team July 8, 2026 12:30
@github-actions github-actions Bot added AL: Apps (W1) Add-on apps for W1 From Fork Pull request is coming from a fork needs-approval Workflow runs require maintainer approval to start labels Jul 8, 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 From Fork Pull request is coming from a fork needs-approval Workflow runs require maintainer approval to start

Projects

None yet

1 participant