Workflow Examples & Troubleshooting
User Interaction Patterns
Simple Entity Request
User: "Generate the account entity from Dataverse"
Response:
- Find next available table ID → 70004
- Navigate:
cd .github\skills\bc-dataverse-entity-generator\scripts - Run:
.\Generate-Entity.ps1 -Entity account -BaseId 70004 - User authenticates in browser (first run only)
- Generated file appears in project root as
CDSaccount.Table.al - Move to
src/Table/and rename toBCSCDSAccount.Table.al - Update table name in file:
"CDS account"→"BCS CDS Account" - Update permission set
- Build project
Using Batch Script
User: "Generate account, contact, and opportunity entities"
Response:
- Edit
.github\skills\bc-dataverse-entity-generator\scripts\Generate-Entity-List.ps1 - Update
$entitiesarray with desired entities and BaseIds - Navigate:
cd .github\skills\bc-dataverse-entity-generator\scripts - Run:
.\Generate-Entity-List.ps1 - Script automatically moves files to
src/Table/with BCS prefix - Update permission set
- Build project
Updating Existing Entity
User: "Regenerate the account entity to get new fields"
Response:
- Find existing table →
BCSCDSAccount.Table.al(e.g., Table 70004) - Navigate:
cd .github\skills\bc-dataverse-entity-generator\scripts - Run generation:
.\Generate-Entity.ps1 -Entity account -BaseId 70004 - Compare field lists between old and new files
- Merge new fields into existing table, preserving custom code/events
- Delete generated duplicate
- Build and test
Multiple Individual Entities
User: "Generate contact and opportunity entities"
Response: Process sequentially, each entity gets its own table ID. Alternative: update Generate-Entity-List.ps1 for batch processing.
Existing Table Merge Strategy
When regenerating an entity that already exists:
# Detect existing table
$entityPattern = "table\s+\d+\s+`"BCS CDS $Entity`""
$existingTable = Get-ChildItem "src/Table/*.al" |
Where-Object { (Get-Content $_.FullName -Raw) -match $entityPattern }
if ($existingTable) {
Write-Host "⚠️ Found existing table: $($existingTable.Name)"
Write-Host "Will merge new fields from generated table"
}
Merge decision matrix:
| Scenario | Action |
|---|---|
| Entity never generated before | Use generated table as-is |
| Entity exists, schema unchanged | Skip generation |
| Entity exists, new fields in Dataverse | Merge new fields into existing |
| Entity exists, fields removed in Dataverse | Manual review required |
| Entity exists, field types changed | Manual review and testing required |
Permission Set Update
After generating a table, add permissions:
permissionset 50100 "BCS Permissions"
{
Assignable = true;
Caption = 'BCS Custom Permissions';
Permissions =
tabledata "BCS CDS Account" = RIMD,
table "BCS CDS Account" = X;
}
Permission levels: R (Read), I (Insert), M (Modify), D (Delete), X (Execute metadata)
Alternative: Use VS Code command AL: Generate permission set containing current extension objects to auto-generate.
Common Entity Names Reference
| Dataverse Entity | AL Table Name | Business Context |
|---|---|---|
| account | BCS CDS Account | Companies/Organizations |
| contact | BCS CDS Contact | People/Individuals |
| lead | BCS CDS Lead | Sales prospects |
| opportunity | BCS CDS Opportunity | Sales opportunities |
| quote | BCS CDS Quote | Sales quotes |
| salesorder | BCS CDS Sales Order | Sales orders |
| invoice | BCS CDS Invoice | Sales invoices |
| product | BCS CDS Product | Products/Items |
| pricelevel | BCS CDS Price Level | Price lists |
| systemuser | BCS CDS System User | CRM users |
| team | BCS CDS Team | User teams |
| organization | BCS CDS Organization | Organization settings |
Troubleshooting
ALTPGen Tool Not Found
# Find installed AL extension version
Get-ChildItem "$env:USERPROFILE\.vscode\extensions" -Filter "ms-dynamics-smb.al-*"
Update $AltpgenPath in Generate-Entity.ps1 to match installed version.
Authentication Fails
- Verify Azure AD App Registration has
Dynamics CRM > user_impersonationpermission - Confirm Redirect URI matches
msal<ClientId>://authformat in app registration - Ensure user has Dataverse environment access
- Try re-running with fresh browser session
Table ID Conflict
- Re-scan
src/Table/*.alfor latest available ID - Check for uncommitted tables in other branches
- Verify
app.jsonID range allows the chosen ID
Files Not Generated
- Verify entity name is correct (lowercase, matches Dataverse schema name)
- Check ALTPGen console output for errors
- Confirm entity exists in target Dataverse environment
- Ensure
$ServiceUripoints to correct environment
Permission Set Syntax Error
- Check comma placement (comma after each permission except last)
- Verify table names are enclosed in double quotes
- Ensure closing semicolon after last permission entry
- Use AL formatter (
Alt+Shift+F) to fix syntax