Skip to content

Commit 65d18f1

Browse files
tpellissierclaude
andcommitted
Fix alternate key creation: include required DisplayName in payload
The EntityKeyMetadata API requires a DisplayName with localized labels. Uses the key_name as the display label by default. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 835976f commit 65d18f1

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

src/PowerPlatform/Dataverse/data/_odata.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1519,6 +1519,21 @@ def _create_alternate_key(self, table_schema_name: str, key_name: str, columns:
15191519
payload = {
15201520
"SchemaName": key_name,
15211521
"KeyAttributes": columns,
1522+
"DisplayName": {
1523+
"@odata.type": "Microsoft.Dynamics.CRM.Label",
1524+
"LocalizedLabels": [
1525+
{
1526+
"@odata.type": "Microsoft.Dynamics.CRM.LocalizedLabel",
1527+
"Label": key_name,
1528+
"LanguageCode": 1033,
1529+
}
1530+
],
1531+
"UserLocalizedLabel": {
1532+
"@odata.type": "Microsoft.Dynamics.CRM.LocalizedLabel",
1533+
"Label": key_name,
1534+
"LanguageCode": 1033,
1535+
},
1536+
},
15221537
}
15231538
r = self._request("post", url, json=payload)
15241539
metadata_id = self._extract_id_from_header(r.headers.get("OData-EntityId"))

0 commit comments

Comments
 (0)