dynamics_create_table
Create a new table (entity) in Dynamics CRM by specifying schema name, display names, and ownership type to organize custom data structures.
Instructions
Cria uma nova tabela (entidade) no Dynamics CRM
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| schemaName | Yes | Nome do schema (ex: new_MyTable) | |
| displayName | Yes | Nome de exibição | |
| displayCollectionName | Yes | Nome de exibição plural | |
| description | No | ||
| primaryAttributeSchemaName | No | Nome do atributo primário | new_name |
| primaryAttributeDisplayName | No | Display name do atributo primário | Nome |
| primaryAttributeMaxLength | No | ||
| ownershipType | No | UserOwned | |
| isActivity | No | ||
| solutionUniqueName | No |
Implementation Reference
- src/tools/schema/index.ts:157-213 (handler)The handler for dynamics_create_table which constructs the entity definition and calls the Dataverse client.
server.tool( "dynamics_create_table", "Cria uma nova tabela (entidade) no Dynamics CRM", CreateTableSchema.shape, async (params: z.infer<typeof CreateTableSchema>) => { const entityData: Record<string, unknown> = { SchemaName: params.schemaName, DisplayName: { "@odata.type": "Microsoft.Dynamics.CRM.Label", LocalizedLabels: [{ "@odata.type": "Microsoft.Dynamics.CRM.LocalizedLabel", Label: params.displayName, LanguageCode: 1046 }], }, DisplayCollectionName: { "@odata.type": "Microsoft.Dynamics.CRM.Label", LocalizedLabels: [{ "@odata.type": "Microsoft.Dynamics.CRM.LocalizedLabel", Label: params.displayCollectionName, LanguageCode: 1046 }], }, Description: { "@odata.type": "Microsoft.Dynamics.CRM.Label", LocalizedLabels: [{ "@odata.type": "Microsoft.Dynamics.CRM.LocalizedLabel", Label: params.description || "", LanguageCode: 1046 }], }, OwnershipType: params.ownershipType, IsActivity: params.isActivity, HasNotes: true, HasActivities: true, PrimaryNameAttribute: params.primaryAttributeSchemaName.toLowerCase(), Attributes: [ { "@odata.type": "Microsoft.Dynamics.CRM.StringAttributeMetadata", SchemaName: params.primaryAttributeSchemaName, DisplayName: { "@odata.type": "Microsoft.Dynamics.CRM.Label", LocalizedLabels: [{ "@odata.type": "Microsoft.Dynamics.CRM.LocalizedLabel", Label: params.primaryAttributeDisplayName, LanguageCode: 1046 }], }, RequiredLevel: { Value: "ApplicationRequired" }, MaxLength: params.primaryAttributeMaxLength, FormatName: { Value: "Text" }, IsPrimaryName: true, }, ], }; let endpoint = "EntityDefinitions"; if (params.solutionUniqueName) { endpoint += `?SolutionUniqueName='${params.solutionUniqueName}'`; } const result = await client.post<{ MetadataId: string }>(endpoint, entityData); return { content: [ { type: "text" as const, text: `Tabela criada com sucesso!\nMetadataId: ${result.MetadataId}\nSchemaName: ${params.schemaName}\nDisplay: ${params.displayName}`, }, ], }; } ); - src/tools/schema/index.ts:12-23 (schema)Zod schema defining the input parameters for dynamics_create_table.
export const CreateTableSchema = z.object({ schemaName: z.string().describe("Nome do schema (ex: new_MyTable)"), displayName: z.string().describe("Nome de exibição"), displayCollectionName: z.string().describe("Nome de exibição plural"), description: z.string().optional(), primaryAttributeSchemaName: z.string().default("new_name").describe("Nome do atributo primário"), primaryAttributeDisplayName: z.string().default("Nome").describe("Display name do atributo primário"), primaryAttributeMaxLength: z.number().default(100), ownershipType: z.enum(["UserOwned", "OrganizationOwned"]).default("UserOwned"), isActivity: z.boolean().default(false), solutionUniqueName: z.string().optional(), }); - src/tools/schema/index.ts:152-155 (registration)The registration function where dynamics_create_table is defined within the server tool registration.
export function registerSchemaTools( server: { tool: Function }, client: DataverseClient ) {