{"kind":"AgentDefinition","metadata":{"namespace":"community","name":"pcf-api-reference","version":"0.1.0"},"spec":{"agents_md":"---\ndescription: 'Complete PCF API reference with all interfaces and their availability in model-driven and canvas apps'\napplyTo: '**/*.{ts,tsx,js}'\n---\n\n# Power Apps Component Framework API Reference\n\nThe 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.\n\n## API Availability\n\nThe following table shows all API interfaces available in the Power Apps component framework, along with their availability in model-driven apps and canvas apps.\n\n| API | Model-driven apps | Canvas apps |\n|-----|------------------|-------------|\n| AttributeMetadata | Yes | No |\n| Client | Yes | Yes |\n| Column | Yes | Yes |\n| ConditionExpression | Yes | Yes |\n| Context | Yes | Yes |\n| DataSet | Yes | Yes |\n| Device | Yes | Yes |\n| Entity | Yes | Yes |\n| Events | Yes | Yes |\n| Factory | Yes | Yes |\n| Filtering | Yes | Yes |\n| Formatting | Yes | Yes |\n| ImageObject | Yes | Yes |\n| Linking | Yes | Yes |\n| Mode | Yes | Yes |\n| Navigation | Yes | Yes |\n| NumberFormattingInfo | Yes | Yes |\n| Paging | Yes | Yes |\n| Popup | Yes | Yes |\n| PopupService | Yes | Yes |\n| PropertyHelper | Yes | Yes |\n| Resources | Yes | Yes |\n| SortStatus | Yes | Yes |\n| StandardControl | Yes | Yes |\n| UserSettings | Yes | Yes |\n| Utility | Yes | Yes |\n| WebApi | Yes | Yes |\n\n## Key API Namespaces\n\n### Context APIs\n\nThe `Context` object provides access to all framework capabilities and is passed to your component's lifecycle methods. It contains:\n\n- **Client**: Information about the client (form factor, network status)\n- **Device**: Device capabilities (camera, location, microphone)\n- **Factory**: Factory methods for creating framework objects\n- **Formatting**: Number and date formatting\n- **Mode**: Component mode and tracking\n- **Navigation**: Navigation methods\n- **Resources**: Access to resources (images, strings)\n- **UserSettings**: User settings (locale, number format, security roles)\n- **Utils**: Utility methods (getEntityMetadata, hasEntityPrivilege, lookupObjects)\n- **WebApi**: Dataverse Web API methods\n\n### Data APIs\n\n- **DataSet**: Work with tabular data\n- **Column**: Access column metadata and data\n- **Entity**: Access record data\n- **Filtering**: Define data filtering\n- **Linking**: Define relationships\n- **Paging**: Handle data pagination\n- **SortStatus**: Manage sorting\n\n### UI APIs\n\n- **Popup**: Create popup dialogs\n- **PopupService**: Manage popup lifecycle\n- **Mode**: Get component rendering mode\n\n### Metadata APIs\n\n- **AttributeMetadata**: Column metadata (model-driven only)\n- **PropertyHelper**: Property metadata helpers\n\n### Standard Control\n\n- **StandardControl**: Base interface for all code components with lifecycle methods:\n  - `init()`: Initialize component\n  - `updateView()`: Update component UI\n  - `destroy()`: Cleanup resources\n  - `getOutputs()`: Return output values\n\n## Usage Guidelines\n\n### Model-Driven vs Canvas Apps\n\nSome APIs are only available in model-driven apps due to platform differences:\n\n- **AttributeMetadata**: Model-driven only - provides detailed column metadata\n- Most other APIs are available in both platforms\n\n### API Version Compatibility\n\n- Always check the API availability for your target platform (model-driven or canvas)\n- Some APIs may have different behaviors across platforms\n- Test components in the target environment to ensure compatibility\n\n### Common Patterns\n\n1. **Accessing Context APIs**\n   ```typescript\n   // In init or updateView\n   const userLocale = context.userSettings.locale;\n   const isOffline = context.client.isOffline();\n   ```\n\n2. **Working with DataSet**\n   ```typescript\n   // Access dataset records\n   const records = context.parameters.dataset.records;\n   \n   // Get sorted columns\n   const sortedColumns = context.parameters.dataset.sorting;\n   ```\n\n3. **Using WebApi**\n   ```typescript\n   // Retrieve records\n   context.webAPI.retrieveMultipleRecords(\"account\", \"?$select=name\");\n   \n   // Create record\n   context.webAPI.createRecord(\"contact\", data);\n   ```\n\n4. **Device Capabilities**\n   ```typescript\n   // Capture image\n   context.device.captureImage();\n   \n   // Get current position\n   context.device.getCurrentPosition();\n   ```\n\n5. **Formatting**\n   ```typescript\n   // Format date\n   context.formatting.formatDateLong(date);\n   \n   // Format number\n   context.formatting.formatDecimal(value);\n   ```\n\n## Best Practices\n\n1. **Type Safety**: Use TypeScript for type checking and IntelliSense\n2. **Null Checks**: Always check for null/undefined before accessing API objects\n3. **Error Handling**: Wrap API calls in try-catch blocks\n4. **Platform Detection**: Check `context.client.getFormFactor()` to adapt behavior\n5. **API Availability**: Verify API availability for your target platform before use\n6. **Performance**: Cache API results when appropriate to avoid repeated calls\n\n## Additional Resources\n\n- 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/)\n- Sample code for each API is available in the [PowerApps-Samples repository](https://github.com/microsoft/PowerApps-Samples/tree/master/component-framework)\n","description":"Complete PCF API reference with all interfaces and their availability in model-driven and canvas apps","import":{"commit_sha":"541b7819d8c3545c6df122491af4fa1eae415779","imported_at":"2026-05-18T20:05:35Z","license_text":"MIT License\n\nCopyright GitHub, Inc.\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.","owner":"github","repo":"github/awesome-copilot","source_url":"https://github.com/github/awesome-copilot/blob/541b7819d8c3545c6df122491af4fa1eae415779/instructions/pcf-api-reference.instructions.md"},"manifest":{}},"content_hash":[128,49,215,240,31,23,43,48,55,54,244,222,162,177,4,56,141,241,237,117,53,61,46,250,45,108,149,167,232,56,112,113],"trust_level":"unsigned","yanked":false}
