Sources as the Data Pipeline
Think of sources as the plumbing between your domain model and the sheet surface. The domain model declares what entity types exist and how they relate. The columns define what users see. Sources sit in between, translating domain relationships into concrete data queries.sources alongside columns, views, renderers, formatters, styles, and sortBy. While columns control presentation and formatters control appearance rules, sources control what data enters the sheet in the first place.
Anatomy of a Source
Each source is an object in thesources array with three main parts:
| Property | Required | Purpose |
|---|---|---|
id | Yes | Unique identifier referenced by other settings |
query | Yes | Defines which entity type to fetch and optional filters |
expand | No | Specifies which navigation properties to traverse |
entityFactory | No | Default property values for newly created records |
name or title | No | Human-readable label for the source |
id is a user-defined string that acts as a reference key. It connects the source to the rest of the sheet configuration. Choose descriptive identifiers that reflect the entity type being queried — for example, user_needs rather than source1.
The Query Object
Thequery property controls data retrieval:
-
from(required) — The entity type name from your domain model. This tells Powersheet which type of work items to load. For example,from: UserNeedfetches all entities of typeUserNeedas defined in yourdomainModelTypes. -
where(optional) — A filter predicate that narrows the result set. The predicate value can be static or dynamic. Dynamic values use the() =>notation to evaluate JavaScript expressions at runtime. This is particularly useful for date-based filtering or parameterized queries. -
take(optional) — Limits the number of records returned. -
orderBy(optional) — Controls server-side ordering of results.
The Expand Property
Theexpand property is where source configuration connects most directly to the domain model. Each entry in the expand array specifies a navigation property name — the same name defined in the domain model’s relationship direct.name or back.name fields.
Expansion can be nested, letting you traverse multi-level hierarchies:
UserNeed entities, expands into the systemRequirements association, and then further into each systemRequirement target entity. Each expansion level corresponds to a new row level in the sheet.
How Cardinality Shapes Sources
The relationship cardinality defined in your domain model dictates the expand pattern and, by extension, the column binding syntax and UI behavior. This is one of the most important concepts to internalize.Many-to-One (N:1)
When a relationship ismany-to-one — for example, many UserNeed entities belong to one Chapter — the source uses the direct navigation property name (singular form). The expand entry is a single level:
chapter renders as a single-value reference picker, and chapter.title lets you display a read-only property of the referenced entity. The key insight is that N:1 relationships do not create new row levels — they add reference columns to the existing level.
One-to-Many (1:N)
The reverse relationship — oneChapter has many UserNeed children — uses the back navigation property name (plural form):
Chapter row, the child UserNeed rows appear beneath it. The column binding for the child level uses the navigation property name directly (e.g., userNeeds) without dot notation.
Many-to-Many (M:N)
Many-to-many relationships are the most complex case. They involve an association entity that sits between the two related types. The source expand requires two levels — one for the association, one for the target entity:systemRequirements.systemRequirement. The association layer (systemRequirements, plural) is the collection of links, while the target layer (systemRequirement, singular) is the actual entity. In the UI, this pattern produces a multi-item reference picker.
The navigation property names in your source
expand must exactly match the direct.name or back.name values in your domain model relationships. A mismatch between the model and the source configuration is one of the most common causes of empty sheets. See Entity Types and Relationships and Link Cardinality for details on how relationships define these names.Entity Factory: Defaults for New Records
TheentityFactory property defines default values that Powersheet assigns when a user creates a new record from within the sheet. This is useful for enforcing consistent initial states:
UserNeed row, the Status field automatically populates with “Draft” and Priority with “Medium”. Without entityFactory, new records would have empty fields (or whatever defaults the underlying platform provides).
Entity factories also support dynamic value expressions:
expand entry can carry its own entityFactory for the child level.
Multiple Sources
A sheet configuration can define multiple sources in thesources array. Each source gets its own id, query, and expansion tree. This allows a single sheet to display data from different root entity types side by side or in separate sections.
The Three-Layer Connection
The relationship between domain model, sources, and columns follows a strict chain:-
Domain model declares entity types (e.g.,
UserNeed,SystemRequirement) and relationships with navigation property names (e.g.,direct.name: chapter,back.name: systemRequirements). -
Sources reference those navigation property names in
expandentries and the entity type names inquery.from. The source does not redefine the relationships — it activates specific paths from the domain model. -
Columns use dot-separated binding paths built from the same navigation property names. The binding path
systemRequirements.systemRequirement.titlemeans: traverse thesystemRequirementsassociation, reach thesystemRequiremententity, and display itstitleproperty.
The interplay between model, source, and column configuration is best verified by loading the sheet in the Powersheet widget and confirming that expansions and column data appear as expected.
Common Misconceptions
“Sources define the schema.” Sources do not define entity types or properties — the domain model does. Sources only specify which parts of the model to query and expand. If you need to add a new entity type, modify the domain model first, then add a source entry. “More expand levels means richer data.” Each expand level adds a data-loading step. Expanding four or five levels deep may produce impressive hierarchy trees but comes at a performance cost. Most practical sheets use one to three expansion levels. “Theid must match the entity type name.” The source id is a free-form string. While it is good practice to use a descriptive name that hints at the entity type (e.g., user_needs for UserNeed), there is no technical requirement for the id to match the from value.
“Dynamic where clauses run on the server.” The () => expressions in where predicates are evaluated on the client side before the query is sent. This means the expression has access to the browser context (including widget parameters) but cannot reference server-side variables directly.
Putting It All Together
Consider a requirements traceability sheet that displaysUserNeed entities at the root, their linked SystemRequirement entities as children, and further nested DesignRequirement entities at the third level:
systemRequirements and designRequirements segments are association-level navigation properties (M:N), while systemRequirement and designRequirement are the target entity-level properties. This pattern — expanding through the association layer then into the entity — is the standard approach for M:N relationships in Powersheet.
Related Topics
For practical steps on configuring sources in your own sheets, see the Sheet Configuration Guides. To understand the domain model relationships that sources reference, see Entity Types and Relationships and Link Cardinality. For a side-by-side comparison of the model and sheet configuration layers, see Data Model vs Sheet Configuration. For details on the() => expression syntax used in where clauses and entity factories, see Dynamic Value Expressions.