@@ -2347,14 +2347,14 @@ def _build_create_entity(
23472347 primary_column : Optional [str ] = None ,
23482348 display_name : Optional [str ] = None ,
23492349 ) -> _RawRequest :
2350- """Build an EntityDefinitions POST request without sending it."""
2350+ """Build an CreateEntities POST request without sending it."""
23512351 if primary_column :
23522352 primary_attr = primary_column
23532353 else :
23542354 primary_attr = f"{ table .split ('_' , 1 )[0 ]} _Name" if "_" in table else "new_Name"
2355- attributes = [self ._attribute_payload (primary_attr , "string" , is_primary_name = True )]
2355+ attributes = [self ._attribute_payload (primary_attr , "string" , is_primary_name = True , complex = True )]
23562356 for col_name , dtype in columns .items ():
2357- attr = self ._attribute_payload (col_name , dtype )
2357+ attr = self ._attribute_payload (col_name , dtype , complex = True )
23582358 if not attr :
23592359 raise ValidationError (
23602360 f"Unsupported column type '{ dtype } ' for column '{ col_name } '." ,
@@ -2366,18 +2366,22 @@ def _build_create_entity(
23662366 raise TypeError ("display_name must be a non-empty string when provided" )
23672367 label = display_name if display_name is not None else table
23682368 body = {
2369- "@odata.type" : "Microsoft.Dynamics.CRM.EntityMetadata" ,
2370- "SchemaName" : table ,
2371- "DisplayName" : self ._label (label ),
2372- "DisplayCollectionName" : self ._label (label + "s" ),
2373- "Description" : self ._label (f"Custom entity for { label } " ),
2374- "OwnershipType" : "UserOwned" ,
2375- "HasActivities" : False ,
2376- "HasNotes" : True ,
2377- "IsActivity" : False ,
2378- "Attributes" : attributes ,
2369+ "Entities" : [
2370+ {
2371+ "@odata.type" : "Microsoft.Dynamics.CRM.ComplexEntityMetadata" ,
2372+ "SchemaName" : table ,
2373+ "DisplayName" : self ._label (label ),
2374+ "DisplayCollectionName" : self ._label (label + "s" ),
2375+ "Description" : self ._label (f"Custom entity for { label } " ),
2376+ "OwnershipType" : "UserOwned" ,
2377+ "HasActivities" : False ,
2378+ "HasNotes" : True ,
2379+ "IsActivity" : False ,
2380+ "Attributes" : attributes ,
2381+ }
2382+ ]
23792383 }
2380- url = f"{ self .api } /EntityDefinitions "
2384+ url = f"{ self .api } /CreateEntities "
23812385 if solution :
23822386 url += f"?SolutionUniqueName={ solution } "
23832387 return _RawRequest (
0 commit comments