Skip to content

Add DISPLAY function: format a field's value by its field type and the running user's locale - #251

Merged
cesarParra merged 3 commits into
mainfrom
display-function
Nov 3, 2026
Merged

cesarParra merged 3 commits into
mainfrom
display-function

Conversation

@cesarParra

@cesarParra cesarParra commented Nov 3, 2026 •

Copy link
Copy Markdown
Owner

What

DISPLAY(field) formats a field's value the way Salesforce shows it to the running user:

Field type DISPLAY returns
Currency symbol plus the field's scale: $1,234.50, $0.30
Percent the field's scale plus %: 30%
Number locale grouping at the field's scale
Date Date.format(), in the user's locale
Datetime Datetime.format(), in the user's locale and time zone
Anything else, or a value that is not a field the value, unchanged

It works on a merge field (Amount), a relationship get (Account.AnnualRevenue), and inside MAP over child records (Opportunities -> MAP(DISPLAY(Amount))).

Why

Prose shows merge fields in notes. A raw Evaluator.run result loses the field's type, so Prose rendered 141.40 without a currency symbol, 0.3 for a $0.30 price, and 2027-03-17 00:00:00 (GMT) for a datetime. Prose will wrap the field references it evaluates in DISPLAY.

Changes

  • DataFunctions.DisplayFn: new standard function.
  • Environment.getContext(): now public, so the function can find the record behind a merge field.
  • Currency symbols cover common ISO codes. Any other currency shows its ISO code. The record's CurrencyIsoCode is used when it was queried; otherwise the user's default currency is used.

Tests

  • 8 new specs in DataFunctionsTest.
  • Full local run: 725 tests, all passing.
  • The function docs are regenerated by the build workflow on push.

Release

Merging releases 1.56.0 automatically: the Build workflow runs on every push to main that touches expression-src, creates and promotes the version (cirrus flow package), regenerates the docs, and commits docs/public/packages.json with the new id.

That workflow has failed since 2026-09-04. The run for 64a74ed created and promoted 1.55.0-1 (04tRb000005c7FJIAY), then stopped at cirrus run docs because apexdocs was not on PATH. Its version bump, alias and packages.json update were never committed, and the next run would have tried to create 1.55.0 again. This PR:

  • records Expression@1.55.0-1 and 1.55.0.NEXT in sfdx-project_packaging.json;
  • points docs/public/packages.json at 1.55.0-1;
  • runs npx apexdocs markdown, so the docs step finds the binary.

Other changes

  • PR Build now runs on the latest Node 22. Salesforce CLI 2.158 crashes on the pinned 22.14.0.
  • DISPLAY is added to the function reference and the editor's autocomplete list.

…e running user's locale

DISPLAY(field) returns currency with its symbol and scale, numbers and
percents at their field scale, and dates and datetimes in the user's locale
and time zone. Values that do not come straight from a field are returned
unchanged. Works on merge fields, relationship gets, and inside MAP over
child records.
…he Build workflow can release again

The 2026-09-04 Build created and promoted 1.55.0-1 (04tRb000005c7FJIAY), then
failed on the docs step because apexdocs was not on PATH, so the version bump,
alias and docs/public/packages.json were never committed. Records them, so the
next release is 1.56.0. Adds DISPLAY to the function reference and the editor's
autocomplete list.
@cesarParra
cesarParra merged commit 6cf68fb into main Nov 3, 2026
1 check passed
@cesarParra
cesarParra deleted the display-function branch November 3, 2026 17:49
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.

1 participant