Lightning Web Component · Data Cloud

DC Segment Viewer: previewing Data Cloud segments without SQL

MVP June 2026

LWC Apex Data Cloud Custom Metadata
Type
Lightning Web Component plus Apex
Stack
LWC, Apex, ConnectApi, Custom Metadata
Tests
Jest and Apex
Status
MVP, version 0.1.0

The problem

A marketer who has just built a segment wants to see who is in it. In Data Cloud that usually means writing SQL against a membership table, which is not a fair ask for a business user.

What it does

  • A workspace for configured segments: pick a segment, preview 25 to 1,000 members.
  • Server-side filters and sorting: contains, equals and starts with.
  • CSV export of the preview rows.
  • Admin setup through Custom Metadata: which segments appear, and which columns each one shows.

How it is built

The component calls an Apex controller, which builds a validated query and runs it through ConnectApi.CdpQuery with bound parameters, joining the segment membership object to the profile object.

The constraint I set for myself was Salesforce-native only: no REST API, no Named Credential, no external worker, no external storage. Users cannot submit SQL or arbitrary field names. The columns configured in metadata are the allowlist, the row cap is enforced in Apex, and everything runs in the current user's security context behind a permission set.

What I learned

  • Sketch before building. I compared three layout alternatives as interactive sketches, then built a synthesis of the best parts.
  • Say what it does not do. Only published membership is queried, and full asynchronous export is deliberately deferred. Stating limits up front beats a feature that half works.

Want to know more?

This project is not public yet. Get in touch if you would like a walkthrough.