Skip to main content
rule official · GitHub

pcf-api-reference: PCF API rule for GitHub Copilot

The rule feeds Copilot a reference of Power Apps component framework interfaces and a table showing which of them work in model-driven and canvas apps.

Install into GitHub Copilot · Manually: put the files in place All methods and platforms ↓
.github/instructions/pcf-api-reference.instructions.md
Open on GitHub

What pcf-api-reference does

## What it covers

The reference lists PCF interfaces and marks where each one runs. Nearly all appear in both app types: Client, Column, ConditionExpression, Context, DataSet, Device, Entity, Events, Factory, Filtering, Formatting, ImageObject, Linking, Mode, Navigation, NumberFormattingInfo, Paging, Popup, PopupService, PropertyHelper, Resources, SortStatus, StandardControl, UserSettings, Utility, WebApi.

One exception stands out. AttributeMetadata ships in model-driven apps only, so a component meant for both hosts cannot pull column metadata through it.

## How the APIs are grouped

Interfaces are sorted by purpose. Context is the entry point: client, device, resources, user settings, navigation and WebApi all arrive through it. Data lives in DataSet, Column, Entity, Filtering, Linking, Paging, SortStatus. Dialogs come from Popup and PopupService. The base StandardControl interface defines the lifecycle: init(), updateView(), destroy(), getOutputs().

## Working rules

The rule tells you to confirm API availability for the target platform before writing code. Some interfaces behave differently between model-driven and canvas, so test the component in the environment it will actually run in. Practical notes: null-check objects, wrap calls in try-catch, cache results, and read the form factor from context.client.getFormFactor().

What it helps with

  • Check whether a PCF interface works in canvas apps, not just model-driven
  • Recall the exact shape of Context and its nested objects
  • Map the component lifecycle onto StandardControl methods
  • Find call examples for WebApi, Device and Formatting

Example prompts for the agent

  • Check the reference for whether AttributeMetadata works in a canvas app
  • List the lifecycle methods on StandardControl
  • Write a context.webAPI.retrieveMultipleRecords call for the account table

How to install pcf-api-reference

Manually: put the files in place

.github/instructions/pcf-api-reference.instructions.md

The applyTo field sets which files it applies to

Step by step, with commands for each platform: AGENTS.md vs CLAUDE.md: what they are and which one to use

Questions about pcf-api-reference

How do I install pcf-api-reference in GitHub Copilot?

Place .github/instructions/pcf-api-reference.instructions.md in your repository. The rule then applies to files matching **/*.{ts,tsx,js}.

What does pcf-api-reference do?

It hands Copilot a reference of Power Apps component framework interfaces plus a table of their availability in model-driven and canvas apps. The agent leans on it while writing component code.

Which PCF APIs are model-driven only?

AttributeMetadata is the one interface on the list that canvas apps lack. Everything else is available in both.

Source text

pcf-api-reference.instructions.md · MIT
---
description: 'Complete PCF API reference with all interfaces and their availability in model-driven and canvas apps'
applyTo: '**/*.{ts,tsx,js}'
---

# Power Apps Component Framework API Reference

The Power Apps component framework provides a rich set of APIs that enable you to create powerful code components. This reference lists all available interfaces and their availability across different app types.

## API Availability

The following table shows all API interfaces available in the Power Apps component framework, along with their availability in model-driven apps and canvas apps.

| API | Model-driven apps | Canvas apps |
|-----|------------------|-------------|
| AttributeMetadata | Yes | No |
| Client | Yes | Yes |
| Column | Yes | Yes |
| ConditionExpression | Yes | Yes |
| Context | Yes | Yes |
| DataSet | Yes | Yes |
| Device | Yes | Yes |
| Entity | Yes | Yes |
| Events | Yes | Yes |
| Factory | Yes | Yes |
| Filtering | Yes | Yes |
| Formatting | Yes | Yes |
| ImageObject | Yes | Yes |
| Linking | Yes | Yes |
| Mode | Yes | Yes |
| Navigation | Yes | Yes |
| NumberFormattingInfo | Yes | Yes |
| Paging | Yes | Yes |
| Popup | Yes | Yes |
| PopupService | Yes | Yes |
| PropertyHelper | Yes | Yes |
| Resources | Yes | Yes |
| SortStatus | Yes | Yes |
| StandardControl | Yes | Yes |
| UserSettings | Yes | Yes |
| Utility | Yes | Yes |
| WebApi | Yes | Yes |

## Key API Namespaces

### Context APIs

The `Context` object provides access to all framework capabilities and is passed to your component's lifecycle methods. It contains:

- **Client**: Information about the client (form factor, network status)
- **Device**: Device capabilities (camera, location, microphone)
- **Factory**: Factory methods for creating framework objects
- **Formatting**: Number and date formatting
- **Mode**: Component mode and tracking
- **Navigation**: Navigation methods
- **Resources**: Access to resources (images, strings)
- **UserSettings**: User settings (locale, number format, security roles)
- **Utils**: Utility methods (getEntityMetadata, hasEntityPrivilege, lookupObjects)
- **WebApi**: Dataverse Web API methods

### Data APIs

- **DataSet**: Work with tabular data
- **Column**: Access column metadata and data
- **Entity**: Access record data
- **Filtering**: Define data filtering
- **Linking**: Define relationships
- **Paging**: Handle data pagination
- **SortStatus**: Manage sorting

### UI APIs

- **Popup**: Create popup dialogs
- **PopupService**: Manage popup lifecycle
- **Mode**: Get component rendering mode

### Metadata APIs

- **AttributeMetadata**: Column metadata (model-driven only)
- **PropertyHelper**: Property metadata helpers

### Standard Control

- **StandardControl**: Base interface for all code components with lifecycle methods:
  - `init()`: Initialize component
  - `updateView()`: Update component UI
  - `destroy()`: Cleanup resources
  - `getOutputs()`: Return output values

## Usage Guidelines

### Model-Driven vs Canvas Apps

Some APIs are only available in model-driven apps due to platform differences:

- **AttributeMetadata**: Model-driven only - provides detailed column metadata
- Most other APIs are available in both platforms

### API Version Compatibility

- Always check the API availability for your target platform (model-driven or canvas)
- Some APIs may have different behaviors across platforms
- Test components in the target environment to ensure compatibility

### Common Patterns

1. **Accessing Context APIs**
   ```typescript
   // In init or updateView
   const userLocale = context.userSettings.locale;
   const isOffline = context.client.isOffline();
   ```

2. **Working with DataSet**
   ```typescript
   // Access dataset records
   const records = context.parameters.dataset.records;
   
   // Get sorted columns
   const sortedColumns = context.parameters.dataset.sorting;
   ```

3. **Using WebApi**
   ```typescript
   // Retrieve records
   context.webAPI.retrieveMultipleRecords("account", "?$select=name");
   
   // Create record
   context.webAPI.createRecord("contact", data);
   ```

4. **Device Capabilities**
   ```typescript
   // Capture image
   context.device.captureImage();
   
   // Get current position
   context.device.getCurrentPosition();
   ```

5. **Formatting**
   ```typescript
   // Format date
   context.formatting.formatDateLong(date);
   
   // Format number
   context.formatting.formatDecimal(value);
   ```

## Best Practices

1. **Type Safety**: Use TypeScript for type checking and IntelliSense
2. **Null Checks**: Always check for null/undefined before accessing API objects
3. **Error Handling**: Wrap API calls in try-catch blocks
4. **Platform Detection**: Check `context.client.getFormFactor()` to adapt behavior
5. **API Availability**: Verify API availability for your target platform before use
6. **Performance**: Cache API results when appropriate to avoid repeated calls

## Additional Resources

- For detailed documentation on each API, refer to the [Power Apps component framework API reference](https://learn.microsoft.com/power-apps/developer/component-framework/reference/)
- Sample code for each API is available in the [PowerApps-Samples repository](https://github.com/microsoft/PowerApps-Samples/tree/master/component-framework)

© github · MIT · github/awesome-copilot

Similar IDE rules

All IDE rules for Frontend and UI →

From the same set928

The whole set →
pcf-community-resources Find PCF component examples, learning videos, developer blogs, and builder tools in one guide. Use it when you need a starting point or help with PCF development. ★ 40,418repo stars pcf-code-components A rule that teaches Copilot how Power Apps code components are built: manifest, TypeScript implementation, resources. Useful when editing ControlManifest.Input.xml or index.ts. ★ 40,418repo stars pcf-canvas-apps Sets GitHub Copilot context for creating PCF controls in canvas apps. Helps handle manifest versioning, security warnings, and environment requirements. ★ 40,418repo stars pcf-best-practices This rule guides Copilot through PCF component lifecycle, API use, and host-specific constraints. Use it when building or changing components for canvas or model-driven apps. ★ 40,418repo stars pcf-alm Instructions for managing PCF code component lifecycles in Microsoft Dataverse. Helps agents configure builds, packaging, and deployments. ★ 40,418repo stars oqtane This rule guides GitHub Copilot when building Oqtane modules with Blazor and C#. Use it for client/server module structure and related code patterns. ★ 40,418repo stars oop-design-patterns A GitHub Copilot rule that steers code generation and refactoring toward GoF design patterns and SOLID principles in object-oriented code. ★ 40,418repo stars object-calisthenics Enforces nine Object Calisthenics design constraints for domain logic in C#, TypeScript, and Java projects using GitHub Copilot. ★ 40,418repo stars

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor