Skip to content

feat(query): build and restore FORMULA() filters in the query builder - #2119

Open
paustint wants to merge 2 commits into
mainfrom
feat/query-builder-formula-filter
Open

paustint wants to merge 2 commits into
mainfrom
feat/query-builder-formula-filter

Conversation

@paustint

@paustint paustint commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

Stacked on #2142 (API version 68.0). The base is chore/sfdc-api-version-68, and GitHub will retarget to main when #2142 merges.

Summary

Adds the Winter '27 SOQL FORMULA() function to the Query Builder filters.

  • A WHERE filter row now has a Field Math function. Choosing Add / Subtract Fields adds a +/- picker and a second field, limits the comparison operators to the ones FORMULA() supports (=, !=, <, <=, >, >=), and composes FORMULA('Amount - ExpectedRevenue') > 100.
  • Field Math is only offered when the first field is a number, currency, percent, date or datetime field. Changing a formula row's field to an unsupported type turns it back into a regular comparison.
  • The Second Field list only offers fields that can be combined with the first one: numbers pair with numbers, a date or datetime pairs with the same type or a number. Relationships stay navigable and the related fields loaded by drilling in are filtered the same way.
  • The row warns when date and datetime fields are mixed.
  • Queries containing FORMULA() restore into the builder, including in subqueries. If either field is unavailable the filter is reported as unsupported, as before.
  • Filter summaries and the subquery tooltip show FORMULA(Amount - ExpectedRevenue).

The row reuses the existing per-row function slot, so the new state is an optional formula operand on ExpressionConditionRowSelectedItems.

Behavior change outside FORMULA

Rows inside a filter group now go through the same condition builder as standalone rows. The group builder previously dropped the row's function, which also affected functions used in grouped HAVING filters.

Closes #2118

Test plan

  • Unit tests: compose (root, grouped, related field, decimal, date arithmetic), queryFilterHasValue, help text, Field Math availability, second field eligibility, restore round trip and unsupported fallback, row render
  • nx typecheck and nx test for the affected projects
  • query-builder.spec.ts E2E locally (the Field locator is now exact since the row has a Field Math label too)
  • Manual: pick the function in a sandbox on API v68.0+, run the query, restore it from history

@paustint
paustint added this pull request to stack #2120 October 2, 2026 21:03
Base automatically changed from feat/soql-formula-support to main October 2, 2026 21:16
@paustint
paustint marked this pull request as draft October 2, 2026 21:19
@paustint
paustint force-pushed the feat/query-builder-formula-filter branch from 09532aa to b6dcf7e Compare October 2, 2026 21:21
@paustint
paustint force-pushed the feat/query-builder-formula-filter branch from b6dcf7e to d931bdb Compare October 11, 2026 14:51
@paustint
paustint removed this pull request from stack #2120 October 11, 2026 14:52
@paustint
paustint changed the base branch from main to chore/sfdc-api-version-68 October 11, 2026 14:52
@paustint
paustint changed the base branch from chore/sfdc-api-version-68 to main October 11, 2026 14:52
@paustint
paustint changed the base branch from main to chore/sfdc-api-version-68 October 11, 2026 14:53
@paustint
paustint added this pull request to stack #2143 October 11, 2026 14:53
Base automatically changed from chore/sfdc-api-version-68 to main October 13, 2026 13:41
@paustint
paustint marked this pull request as ready for review October 14, 2026 22:30
Copilot AI balanced review requested due to automatic review settings October 14, 2026 22:30
@paustint
paustint force-pushed the feat/query-builder-formula-filter branch from d931bdb to 468f02c Compare October 14, 2026 22:30

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Second-field selection can overwrite newer edits, and formula fallback can leave incorrect value controls.

3 open findings
What changed in this PR

Adds FORMULA() arithmetic filters to Jetstream’s Query Builder, including query restoration and summaries.

Changes:

  • Adds field-math controls and compatible second-field filtering.
  • Composes and restores FORMULA() conditions, including subqueries, and preserves grouped filter functions.
  • Adds unit coverage and updates field locators.
File Description
libs/​ui/​src/​lib/​expression-group/​ExpressionContainer.tsx Propagates formula rules and refreshes row metadata.
libs/​ui/​src/​lib/​expression-group/​ExpressionConditionRow.tsx Adds math and second-field controls.
libs/​types/​src/​lib/​ui/​types.ts Defines formula operands and filtering callbacks.
libs/​test/​e2e-utils/​src/​lib/​pageObjectModels/​QueryPage.model.ts Makes Field locators exact.
libs/​shared/​ui-utils/​src/​lib/​shared-ui-utils.ts Composes formula conditions and summary text.
libs/​shared/​ui-core/​src/​query/​RestoreQuery/​query-restore-utils.ts Restores formula operands.
libs/​shared/​ui-core/​src/​query/​RestoreQuery/​__tests__/​query-restore-utils.spec.ts Tests restoration and unavailable fields.
libs/​shared/​ui-core-shared/​src/​query-filter.utils.ts Defines compatibility rules and warnings.
libs/​shared/​constants/​src/​lib/​query-filter-constants.ts Adds formula constants.
libs/​shared/​constants/​src/​index.ts Exports formula constants.
libs/​features/​query/​src/​QueryOptions/​QueryFilter.tsx Enables Field Math for WHERE filters.
libs/​features/​query/​src/​QueryOptions/​accordion-titles/​QueryFilterTitleSummary.tsx Displays formula summaries.
libs/​features/​query/​src/​QueryOptions/​__tests__/​query-filter-formula.spec.ts Tests composition and field eligibility.
libs/​features/​query/​src/​QueryOptions/​__tests__/​query-filter-formula-row.spec.tsx Tests controls and field choices.
libs/​features/​query/​src/​QueryBuilder/​QuerySubqueryLevel.tsx Includes formulas in subquery tooltips.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread libs/ui/src/lib/expression-group/ExpressionConditionRow.tsx
Comment thread libs/features/query/src/QueryOptions/QueryFilter.tsx Outdated
Comment thread libs/shared/ui-core-shared/src/query-filter.utils.ts
Field pickers that can drill into related objects kept using the row as it
was when the picker first appeared. Changing the field on an existing filter,
order by or group by row undid the operator, value, sort direction or function
chosen since, and the mass update alternate field picker could undo other
option changes the same way.
Choosing "Add / Subtract Fields" under Field Math on a WHERE filter row adds a
math operator and a second field, limits the comparison operators to the ones
FORMULA() supports, and composes to FORMULA('A - B') > 100. Field Math is
only offered for number, currency, date and datetime fields, the second field
only lists fields that can be combined with the first, and rows warn when
date and datetime fields are mixed. Changing the first field to one Field Math
does not support turns the row back into a regular filter. The help text notes
that FORMULA() is a beta, available only in sandbox, Developer Edition and
scratch orgs on API v68.0+.

Filter rows inside a group now go through the same builder as standalone
rows. The group builder previously dropped the row's function, which also
affected functions used in grouped HAVING filters.

Closes #2118
Copilot AI balanced review requested due to automatic review settings October 15, 2026 19:15
@paustint
paustint force-pushed the feat/query-builder-formula-filter branch from 468f02c to 4d30e4f Compare October 15, 2026 19:15

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Restoration can change query meaning, and unresolved literal handling, warning initialization, and filtering performance issues remain.

4 open findings
3 resolved since last review

🧠 Review effort: Balanced

Comment thread libs/shared/ui-core/src/query/RestoreQuery/query-restore-utils.ts
Comment thread libs/shared/ui-core-shared/src/query-filter.utils.ts
Comment thread libs/shared/ui-core/src/query/RestoreQuery/query-restore-utils.ts
Comment thread libs/shared/ui-utils/src/lib/shared-ui-utils.ts

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Query builder: add UI to build SOQL FORMULA() filters

2 participants