Skip to content

Commit fc83332

Browse files
committed
Move to Create Entities API for table creation
1 parent 5eae887 commit fc83332

1 file changed

Lines changed: 12 additions & 12 deletions

File tree

src/PowerPlatform/Dataverse/data/_odata.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1190,9 +1190,9 @@ def _create_entity(
11901190
attributes: List[Dict[str, Any]],
11911191
solution_unique_name: Optional[str] = None,
11921192
) -> Dict[str, Any]:
1193-
url = f"{self.api}/EntityDefinitions"
1194-
payload = {
1195-
"@odata.type": "Microsoft.Dynamics.CRM.EntityMetadata",
1193+
url = f"{self.api}/CreateEntities"
1194+
payload = {"Entities" :[{
1195+
"@odata.type": "Microsoft.Dynamics.CRM.ComplexEntityMetadata",
11961196
"SchemaName": table_schema_name,
11971197
"DisplayName": self._label(display_name),
11981198
"DisplayCollectionName": self._label(display_name + "s"),
@@ -1202,7 +1202,7 @@ def _create_entity(
12021202
"HasNotes": True,
12031203
"IsActivity": False,
12041204
"Attributes": attributes,
1205-
}
1205+
}]}
12061206
params = None
12071207
if solution_unique_name:
12081208
params = {"SolutionUniqueName": solution_unique_name}
@@ -1590,7 +1590,7 @@ def _attribute_payload(
15901590
label = column_schema_name.split("_")[-1]
15911591
if dtype_l in ("string", "text"):
15921592
return {
1593-
"@odata.type": "Microsoft.Dynamics.CRM.StringAttributeMetadata",
1593+
"@odata.type": "Microsoft.Dynamics.CRM.ComplexStringAttributeMetadata",
15941594
"SchemaName": column_schema_name,
15951595
"DisplayName": self._label(label),
15961596
"RequiredLevel": {"Value": "None"},
@@ -1600,7 +1600,7 @@ def _attribute_payload(
16001600
}
16011601
if dtype_l in ("memo", "multiline"):
16021602
return {
1603-
"@odata.type": "Microsoft.Dynamics.CRM.MemoAttributeMetadata",
1603+
"@odata.type": "Microsoft.Dynamics.CRM.ComplexMemoAttributeMetadata",
16041604
"SchemaName": column_schema_name,
16051605
"DisplayName": self._label(label),
16061606
"RequiredLevel": {"Value": "None"},
@@ -1610,7 +1610,7 @@ def _attribute_payload(
16101610
}
16111611
if dtype_l in ("int", "integer"):
16121612
return {
1613-
"@odata.type": "Microsoft.Dynamics.CRM.IntegerAttributeMetadata",
1613+
"@odata.type": "Microsoft.Dynamics.CRM.ComplexIntegerAttributeMetadata",
16141614
"SchemaName": column_schema_name,
16151615
"DisplayName": self._label(label),
16161616
"RequiredLevel": {"Value": "None"},
@@ -1620,7 +1620,7 @@ def _attribute_payload(
16201620
}
16211621
if dtype_l in ("decimal", "money"):
16221622
return {
1623-
"@odata.type": "Microsoft.Dynamics.CRM.DecimalAttributeMetadata",
1623+
"@odata.type": "Microsoft.Dynamics.CRM.ComplexDecimalAttributeMetadata",
16241624
"SchemaName": column_schema_name,
16251625
"DisplayName": self._label(label),
16261626
"RequiredLevel": {"Value": "None"},
@@ -1640,7 +1640,7 @@ def _attribute_payload(
16401640
}
16411641
if dtype_l in ("datetime", "date"):
16421642
return {
1643-
"@odata.type": "Microsoft.Dynamics.CRM.DateTimeAttributeMetadata",
1643+
"@odata.type": "Microsoft.Dynamics.CRM.ComplexDateTimeAttributeMetadata",
16441644
"SchemaName": column_schema_name,
16451645
"DisplayName": self._label(label),
16461646
"RequiredLevel": {"Value": "None"},
@@ -1649,12 +1649,12 @@ def _attribute_payload(
16491649
}
16501650
if dtype_l in ("bool", "boolean"):
16511651
return {
1652-
"@odata.type": "Microsoft.Dynamics.CRM.BooleanAttributeMetadata",
1652+
"@odata.type": "Microsoft.Dynamics.CRM.ComplexBooleanAttributeMetadata",
16531653
"SchemaName": column_schema_name,
16541654
"DisplayName": self._label(label),
16551655
"RequiredLevel": {"Value": "None"},
16561656
"OptionSet": {
1657-
"@odata.type": "Microsoft.Dynamics.CRM.BooleanOptionSetMetadata",
1657+
"@odata.type": "Microsoft.Dynamics.CRM.ComplexBooleanOptionSetMetadata",
16581658
"TrueOption": {
16591659
"Value": 1,
16601660
"Label": self._label("True"),
@@ -1668,7 +1668,7 @@ def _attribute_payload(
16681668
}
16691669
if dtype_l == "file":
16701670
return {
1671-
"@odata.type": "Microsoft.Dynamics.CRM.FileAttributeMetadata",
1671+
"@odata.type": "Microsoft.Dynamics.CRM.ComplexFileAttributeMetadata",
16721672
"SchemaName": column_schema_name,
16731673
"DisplayName": self._label(label),
16741674
"RequiredLevel": {"Value": "None"},

0 commit comments

Comments
 (0)