# PBI Template Patterns

When requirements match one of these patterns, follow the template format. The `[brackets]` are filled in from the actual requirements.

## Create New Table
```
Title: Create [table name] table
Description:
  AS A [user/role]
  I WANT a new table to exist called [table name]
  SO THAT [business purpose]

  Implementation Details:
  - Create new table called [table name] (plural: [plural name])
  - Add fields to [table name] and main form as described in the field-level matrix
  - Add [table name] to the sitemap under [area, group]
Acceptance Criteria:
  GIVEN [user/role]
  WHEN I access the app and view the [sitemap area]
  THEN a new table called [table name] will be visible
  GIVEN [user/role]
  WHEN I create or open a record
  THEN I will see the form layout with fields, sections, and tabs as specified
```

## Create System Views
```
Title: Create system views for [table name] table
Description:
  AS A [user/role]
  I WANT the columns to be set for the [table name] system views
  SO THAT I can search/sort/filter data

  Implementation Details:
  - Active [table name] View
  - Inactive [table name] View
  - All [table name] View
  - [Other custom views as needed]
  - Columns: [list in order]
  - Sort: [field, direction]
Acceptance Criteria:
  GIVEN [user/role]
  WHEN I view any system view for [table name]
  THEN the view will have the columns, sorting, and filtering as specified
```

## Add Subgrid to Form
```
Title: Add subgrid of [child table] to [parent table] form
Description:
  AS A [user/role]
  I WANT a subgrid of [child table] records on the [parent table] main form
  SO THAT I can see related [child table] records at a glance

  Implementation Details:
  - Location: [tab], [section]
  - Subgrid label: [label]
  - Filters: [any filters]
  - Columns: [list]
Acceptance Criteria:
  GIVEN [user/role]
  WHEN I view a [parent table] record
  THEN I will see a subgrid of related [child table] records
```

## Add Quick View Form
```
Title: Add [table name] quick view form to [parent table] form
Description:
  AS A [user/role]
  I WANT a quick view of [child table] on the [parent table] form
  SO THAT I can see [fields] without leaving the parent form

  Implementation Details:
  - Create quick view form for [child table] with fields: [list]
  - Add to [parent table] main form on [tab], [section]
Acceptance Criteria:
  GIVEN [user/role]
  WHEN I open [parent table] form and populate [lookup field]
  THEN I will see a quick view of the related [child table] record
```

## Hide/Show Field, Section, or Tab
```
Title: Hide/show [target] on [form name]
Description:
  AS A [user/role]
  I WANT [target] to be hidden when [condition]
  SO THAT I only see it when relevant

  Implementation Details:
  - Default: [hidden or shown]
  - Criteria to hide: [conditions]
  - Criteria to show: [conditions]
Acceptance Criteria:
  GIVEN [user/role]
  WHEN I [action to meet hide criteria]
  THEN [target] will be hidden
  GIVEN [user/role]
  WHEN I [action to meet show criteria]
  THEN [target] will be displayed
```

## Calculated Field
```
Title: Determine [field name] - [table name] (calculated field)
Description:
  AS A [user/role]
  I WANT [field name] on [table name] to be calculated
  SO THAT I can understand [what the field tells the user]

  Implementation Details:
  - Trigger(s): [what triggers recalculation]
  - Fields involved: [field names with schema names and tables]
  - Logic: [calculation logic]
Acceptance Criteria:
  GIVEN [user/role]
  WHEN [trigger occurs]
  THEN [field name] will be calculated based on the specified logic
```

## Notification / Power Automate Flow
```
Title: Notify [audience] of [content] when [trigger]
Description:
  AS A [user/role]
  I WANT to be notified via [channel] when [trigger]
  SO THAT I know when [purpose]

  Implementation Details:
  - Notification type: [Email/Teams/In-app]
  - Trigger: [what triggers it]
  - Sender: [who sends]
  - Recipient: [who receives]
  - Subject: [subject line]
  - Body: [content, specify static vs dynamic text]
Acceptance Criteria:
  GIVEN I am [recipient]
  WHEN [trigger occurs]
  THEN I will receive a notification with the specified content
```

## Secure Table Records
```
Title: Secure [table name] records
Description:
  AS A [admin/role]
  I WANT table permissions set for all security roles
  SO THAT access to [table name] records is controlled

  Implementation Details:
  - Apply permissions for [table name] for roles: [list roles]
  - See security role x table permissions matrix: [link/reference]
Acceptance Criteria:
  GIVEN [role 1]
  WHEN I access a [table name] record
  THEN my actions are restricted per the permissions matrix
```

## Configure Search
```
Title: Configure search for [table name]
Description:
  AS A [user/role]
  I WANT to search for [table name] records using Dataverse and Advanced Find
  SO THAT I can quickly find the data I need

  Implementation Details:
  - Enable for Advanced Find
  - Enable for Dataverse search
  - Default find columns: [list]
  - Advanced Find view columns: [list]
Acceptance Criteria:
  GIVEN [user/role]
  WHEN I search for [table name] in Dataverse search
  THEN I can search on the specified find columns
```

## Dashboard
```
Title: Create [dashboard name] dashboard
Description:
  Business Need: [what information the dashboard surfaces]

  Implementation Details:
  - Dashboard name: [name]
  - Components:
    - [Component 1]: [chart type / view name, entity, filters, columns]
    - [Component 2]: [chart type / view name, entity, filters, columns]
Acceptance Criteria:
  GIVEN [user/role]
  WHEN I navigate to the [dashboard name] dashboard
  THEN I will see the components with the data as specified
```

## Business Process Flow
```
Title: Create [BPF name] business process flow
Description:
  AS A [user/role]
  I WANT a business process flow to guide me through [process]
  SO THAT I follow the correct steps

  Implementation Details:
  - Entity: [primary table]
  - Stages: [list stages with fields per stage]
  - Branching: [any conditional branching]
Acceptance Criteria:
  GIVEN [user/role]
  WHEN I create/open a [table] record
  THEN the BPF guides me through the specified stages
```

## Create Security Role
```
Title: Create [security role name] security role
Description:
  AS A system administrator
  I WANT a [security role name] role to exist
  SO THAT access to [functional area] is controlled

  Implementation Details:
  - Role name: [name]
  - Note: Table permissions for this role are defined in the security matrix and applied in separate PBIs
Acceptance Criteria:
  GIVEN I am a system administrator
  WHEN I manage roles for a user
  THEN [security role name] is available to assign
```

## Standard Scaffold PBIs

These PBIs are created under the standard scaffold Features for every project:

### Infrastructure > General App Setup
- Provision Service Principal
- Create Sitemap Layout
- Create App Name
- Create Model Driven App
- Create Icons for Custom Tables

### Infrastructure > SharePoint Environments
- Provision Dev/Test/Prod SharePoint Sites

### Infrastructure > Solution Management
- Create source code repository / structure
- Update publisher prefix
- Setup Deployment Pipeline

### Infrastructure > Power Platform Environments
- Provision Dev/Test/Prod Power App Environments

### Infrastructure > Power Pages Environments (if applicable)
- Provision Dev/Test/Prod Power Pages Environments

### Infrastructure > Deployment
- Create Production Deployment Checklist

### Security > Business Units
- Create Business Units

### Security > Security Roles
- Create [security role name] security role (one per role)

### Security > SharePoint Document Management Security
- Create SharePoint Document Retention Policies

### Supporting Documents > Templates
- Sitemap Layout Template
- Field-level Matrix Template
- Security Role x Table Matrix Template
- Standard User Story States & Definition
- Data Migration Mapping Template
