Power Platform QA Solution
Power Platform QA
Home
Solutions
Reports
Settings
User Guide
Back to Analyzers
Configure Analyzer —
Collection Usage Count
CUSTOM
Metadata
ID
collection-usage-count
Result Key
collectionUsageCount
File
collection-usage-count.js
Built-in
No
Analyzer Classification
Category
— This determines the type of Analyzer you are building. Categories can be set up under settings.
Uncategorized
Performance
Data Operations
Variables & Scoping
Maintenance
Test sets
— Include this analyzer in predefined runs. Select one or more test sets this analyzer should belong to.
Dataverse test set
Some tests
Description
Counts the total number of collections that are referenced in the app
Prompt
Provider
Anthropic (Claude) — no key
OpenAI (GPT) — no key
Google (Gemini) — no key
Re-run AI builder
Count the number of collections that are used.
Source Code
collection-usage-count.js ·
Input data reference ↗
Checking…
Save JavaScript
export default { name: "Collection Usage Count", description: "Counts the total number of collections that are referenced in the app", resultKey: "collectionUsageCount", resultSchema: { keys: [ { key: 'name', label: 'Name', suggestedFormat: 'name-copy' }, { key: 'type', label: 'Type', suggestedFormat: 'badge-info' }, { key: 'confidence', label: 'Confidence', suggestedFormat: 'badge-confidence' }, { key: 'message', label: 'Details', suggestedFormat: 'text-sm' }, { key: 'locations', label: 'Locations', suggestedFormat: 'locations' } ] }, analyze(controlTree, refGraph, extraction) { const results = []; // Get all unique collections that are read from const collectionsRead = refGraph.collectionsRead || new Set(); // Get all unique collections that are written to const collectionsWritten = new Set(); if (extraction.collectionWrites) { for (const collectionName of extraction.collectionWrites.keys()) { collectionsWritten.add(collectionName); } } // Combine both read and written collections for total unique count const allCollections = new Set([...collectionsRead, ...collectionsWritten]); if (allCollections.size > 0) { // Create a single result with the count const collectionList = Array.from(allCollections).sort(); const locations = []; // Add locations for collection writes if (extraction.collectionWrites) { for (const collectionName of collectionList) { const writes = extraction.collectionWrites.get(collectionName); if (writes && writes.length > 0) { locations.push({ control: writes[0].control, property: writes[0].property, file: writes[0].file, snippet: writes[0].snippet }); } } } // If no write locations found, try to find read references from formulas if (locations.length === 0 && extraction.allFormulas) { for (const collectionName of collectionList) { const formula = extraction.allFormulas.find(f => f.formula && f.formula.includes(collectionName) ); if (formula) { locations.push({ control: formula.control, property: formula.property, file: formula.file }); break; // Just need one location for the summary } } } results.push({ name: "Collection Usage Summary", type: "collection-usage-count", message: `Found ${allCollections.size} collection${allCollections.size === 1 ? '' : 's'} used in the app: ${collectionList.join(', ')}`, locations: locations.length > 0 ? locations : [{ control: "App", property: "Analysis", file: "app.pa.yaml" }], confidence: "high" }); } else { results.push({ name: "Collection Usage Summary", type: "collection-usage-count", message: "No collections found in the app", locations: [{ control: "App", property: "Analysis", file: "app.pa.yaml" }], confidence: "high" }); } return results; } };
Report Output Columns
Columns shown in the generated report. Toggle off to hide; pick a declared key or use "Custom…" for dot-paths like
locations.0.file
.
+ Add column
Enabled
Key
Label
Format
Width
message
Plain text
Small text
Muted grey text
Code snippet
Number (right-aligned)
Percentage (%)
Truncate at 80 chars
Truncate at 120 chars
Info pill (blue)
Confidence pill (red/yellow/grey)
Dead-code type pill
Bold name + copy button
Locations list
×
Cancel
Test analyzer
Save Columns
Running analyzer against solution…
This can take up to a minute for large solutions.
Test Collection Usage Count
×
Runs this analyzer in isolation against the chosen solution. Nothing is saved — the result is shown here only.
Use an existing solution
No solutions uploaded yet
Upload a solution file
Cancel
Run test
Test results
×