Constraints in Powersheet

Modified on Fri, 27 Feb at 6:24 PM


Constraints are filtering rules that determine which Polarion work items are loaded, selectable, and creatable in Powersheet. By defining constraints in your Model or Sheet configuration, you can ensure users only interact with the relevant slice of data. This article covers all available constraint types, stages, operators, and configuration options.


TABLE OF CONTENTS


What are constraints?

Constraints define filtering rules that control which Polarion work items are loaded, selectable, and creatable within Powersheet. They can be applied to both entity types (domainModelTypes) and relationships.

Think of constraints as database queries that Powersheet automatically applies behind the scenes; they ensure users only see and interact with the right slice of data.


Configuration of Constraints in the Model

Where Constraints Can Be Applied

Constraints can be placed in two locations:


1. On an entity type: applies to all instances of that type

domainModelTypes:
  SystemRequirement:
    polarionType: sys_req
    properties:
      - description
      - severity
    constraints:
      load:
        document:
          type: systemRequirementsSpecification


2. On a relationship navigation propertyapplies when traversing that relationship:

relationships:
  - from: SystemRequirement
    to: UserNeed
    cardinality: many-to-many
    storage: linkedWorkItems
    linkRole: decomposes
    direct:
      name: userNeeds
    back:
      name: systemRequirements
      constraints:
        load:
          document:
            type: systemRequirementsSpecification


Constraint Stages

Constraints have three stages, each controlling a different user interaction:


StageKeywordWhen it applies
LoadloadWhen Powersheet initially fetches data from Polarion
PickpickWhen a user opens a picker dialog to select/link an item
CreatecreateWhen a user creates a new work item


Stage Cascading (Fallback Behavior)

Stages cascade upward — more specific stages automatically include constraints from less specific ones:

  • Load stage: uses only load constraints
  • Pick stage: uses load + pick constraints (combined with AND)
  • Create stage: uses load + pickcreate constraints (combined with AND)


Fallback rule: If no create constraints are defined, the system automatically uses pick constraints for the create stage instead.



This means that if you only define a load constraint, it will apply everywhere:  during initial load, in pickers, and when creating items.

You only need pick or create constraints when you want additional filtering beyond what load provides.



Example — load + pick constraints:


domainModelTypes:
  SystemRequirement:
    polarionType: sys_req
    constraints:
      load:
        document:
          type: systemRequirementsSpecification
      pick:
        document:
           moduleFolder: Requirements 


In this example:

  • Initial load: filters by document type only
  • Picker dialog: filters by document type AND document module folder
  • Create: filters by document type AND document module folder (inherits pick since no create is defined)

Constrainable Properties

Constraints support document navigation properties:

constraints:
  load:
    document:
      type: systemRequirementsSpecification    # document type
      id: Requirements/UserNeedSpecification   # document ID (folder/name)
      moduleName: UserNeedSpecification        # document module name
      moduleFolder: Requirements               # document module folder
      component: Braking                       # document component
      title: My Specification                  # document title



Important limitation: Only document properties are supported for constraints. Filtering by direct work item data properties (like priority, status, etc.) in the constraint query is not supported at this time.



Comparison Operators

By default, a constraint value means equals. You can use comparison operators for more flexible matching:

constraints:
  load:
    document:
      # Exact match (default)
      type: systemRequirementsSpecification

      # Contains
      moduleName:
        contains: Specification

      # In (match any value in a list)
      type:
        in: [systemRequirementsSpecification, designRequirementsSpecification]

      # Starts with
      title:
        startsWith: REQ-

      # Ends with
      title:
        endsWith: -Draft



OperatorExampleDescription
(default)type: sys_reqEquals
containsmoduleName: { contains: Spec }Value contains the specified text
intype: { in: [a, b] }Value matches any option in list
startsWithtitle: { startsWith: REQ- }Value starts with prefix
endsWithtitle: { endsWith: -Draft }Value ends with suffix


Logical Operators (AND / OR)

You can use and and or operators inside navigation properties for complex filtering.

  • Load items from document "Alpha" OR document "Beta":
constraints:
  load:
    document:
      or:
        - moduleName: Alpha
        - moduleName: Beta


  • Load items from documents whose name contains "Spec" AND are in the "Requirements" folder
constraints:
  load:
    document:
      moduleName:
        contains: Spec
      moduleFolder: Requirements


Important rule: The document filter must always be at the top level of the constraint. You can put or/and logic inside it, but you cannot wrap document: inside an or: block.



This works:

document:
  or:
    - moduleName: DocA
    - moduleName: DocB


This does NOT work:

# Invalid — document is inside or, not at top level
or:
  - document:
      moduleName: DocA
  - document:
      moduleName: DocB


Dynamic Constraints with $context

Constraints can reference values from the current context using the $context syntax. This is particularly useful for relationship constraints where you want downstream items to be filtered based on the upstream item's properties.

relationships:
  - from: DesignRequirement
    to: SystemRequirement
    cardinality: many-to-many
    storage: linkedWorkItems
    linkRole: decomposes
    direct:
      name: systemRequirements
    back:
      name: designRequirements
      constraints:
        load:
          document:
            component: $context.source.document.component

In this example, when loading Design Requirements linked to a System Requirement, Powersheet will automatically filter them to only show items whose document component matches the component of the source System Requirement's document. This creates component-based data routing.



Available context paths:

PathDescription
$context.source.*Properties of the source entity itself
$context.source.document.*Properties of the source entity's document


Dynamic constraints are evaluated at runtime for each row, so different rows can have different constraint values based on their individual context.


Constraint Composition (AND Logic)

When constraints are defined at multiple levels, such as on an entity type and a relationship, or combined with the sheet-level applyCurrentDocumentTo constraint, they are automatically combined using AND logic.

All constraints must be satisfied simultaneously.


Example:

domainModelTypes:
  SystemRequirement:
    polarionType: sys_req
    constraints:
      load:
        document:
          type: systemRequirementsSpecification

relationships:
  - from: DesignRequirement
    to: SystemRequirement
    back:
      name: designRequirements
      constraints:
        load:
          document:
            moduleName:
              contains: Alpha


When loading SystemRequirements through this relationship, the effective constraint is:

document.type = systemRequirementsSpecification  AND  document.moduleName contains "Alpha"


Watch out for conflicts: If entity-level and relationship-level constraints specify incompatible values for the same property (e.g., document.type = A and document.type = B), the AND composition will result in no matching items — this is expected behavior, not an error. Powersheet does not warn about conflicting constraints.



Initial Values from Constraints

When a user creates a new work item, Powersheet automatically uses constraint values as initial defaults. 

For example, if a load constraint specifies document.type: systemRequirementsSpecification, newly created items will be automatically assigned to a document of that type.

This ensures new items are always created within the scope defined by the constraints.


Constraints Quick Reference

FeatureSyntaxExample
Load constraintload:load: { document: { type: srs } }
Pick constraintpick:pick: { document: { moduleFolder: Reqs } }
Create constraintcreate:create: { document: { type: srs } }
Document filterdocument: { prop: value }document: { type: srs }
Contains operator{ contains: value }moduleName: { contains: Spec }
In operator{ in: [a, b] }type: { in: [srs, drs] }
OR inside documentor: [...]document: { or: [{ moduleName: A }, { moduleName: B }] }
Dynamic context$context.source.*component: $context.source.document.component
On entity typeUnder domainModelTypes.*.constraintsSee examples above
On relationshipUnder relationships.*.direct/back.constraintsSee examples above

Configuration of Constraints in Sheet

Current Document Constraint

This is a special client-side constraint for filtering entities by the currently open document.
It is configured in the sheet configuration using the applyCurrentDocumentTo property under the sources.constraints section.

It accepts:

  • An entity type name
  • A navigation path (e.g., systemRequirements.systemRequirement.designRequirements) — not supported yet

It is disabled by default.


Example:

source:
  query:
    from: UserNeed
  constraints:
    applyCurrentDocumentTo: UserNeed

Conclusion

Constraints give you fine-grained control over the data you interact with in Powersheet. Once configured, they work silently in the background — ensuring the right data is available when loading, selecting, and creating work items.


For any assistance, please don’t hesitate to reach out by submitting a ticket here.


Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select at least one of the reasons
CAPTCHA verification is required.

Feedback sent

We appreciate your effort and will try to fix the article