update_dataverse_table
Modify existing Dataverse table properties including display names, descriptions, and feature settings like activities, notes, auditing, and duplicate detection.
Instructions
Updates the properties and configuration of an existing Dataverse table. Use this to modify table settings like display names, descriptions, or feature enablement (activities, notes, auditing, etc.). Changes are published automatically.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| description | No | New description of the table | |
| displayCollectionName | No | New display collection name for the table | |
| displayName | No | New display name for the table | |
| hasActivities | No | Whether the table can have activities | |
| hasNotes | No | Whether the table can have notes | |
| isAuditEnabled | No | Whether auditing is enabled | |
| isConnectionsEnabled | No | Whether connections are enabled | |
| isDocumentManagementEnabled | No | Whether document management is enabled | |
| isDuplicateDetectionEnabled | No | Whether duplicate detection is enabled | |
| isMailMergeEnabled | No | Whether mail merge is enabled | |
| isValidForQueue | No | Whether records can be added to queues | |
| logicalName | Yes | Logical name of the table to update |
Implementation Reference
- src/tools/table-tools.ts:216-313 (handler)Executes the tool logic: Retrieves existing table metadata, merges provided updates for display names, descriptions, and feature flags (activities, notes, audit, etc.), performs a PUT request with MSCRM.MergeLabels header to update labels safely, publishes the customization, and returns success or error response.async (params) => { try { // First, retrieve the current entity definition const currentEntity = await client.getMetadata<EntityMetadata>( `EntityDefinitions(LogicalName='${params.logicalName}')` ); // Create the updated entity definition by merging current with new values const updatedEntity: any = { ...currentEntity, "@odata.type": "Microsoft.Dynamics.CRM.EntityMetadata" }; // Update only the specified properties if (params.displayName) { updatedEntity.DisplayName = createLocalizedLabel(params.displayName); } if (params.displayCollectionName) { updatedEntity.DisplayCollectionName = createLocalizedLabel(params.displayCollectionName); } if (params.description) { updatedEntity.Description = createLocalizedLabel(params.description); } if (params.hasActivities !== undefined) { updatedEntity.HasActivities = params.hasActivities; } if (params.hasNotes !== undefined) { updatedEntity.HasNotes = params.hasNotes; } if (params.isAuditEnabled !== undefined) { updatedEntity.IsAuditEnabled = { Value: params.isAuditEnabled, CanBeChanged: true, ManagedPropertyLogicalName: "canmodifyauditsettings" }; } if (params.isDuplicateDetectionEnabled !== undefined) { updatedEntity.IsDuplicateDetectionEnabled = { Value: params.isDuplicateDetectionEnabled, CanBeChanged: true, ManagedPropertyLogicalName: "canmodifyduplicatedetectionsettings" }; } if (params.isValidForQueue !== undefined) { updatedEntity.IsValidForQueue = { Value: params.isValidForQueue, CanBeChanged: true, ManagedPropertyLogicalName: "canmodifyqueuesettings" }; } if (params.isConnectionsEnabled !== undefined) { updatedEntity.IsConnectionsEnabled = { Value: params.isConnectionsEnabled, CanBeChanged: true, ManagedPropertyLogicalName: "canmodifyconnectionsettings" }; } if (params.isMailMergeEnabled !== undefined) { updatedEntity.IsMailMergeEnabled = { Value: params.isMailMergeEnabled, CanBeChanged: true, ManagedPropertyLogicalName: "canmodifymailmergesettings" }; } if (params.isDocumentManagementEnabled !== undefined) { updatedEntity.IsDocumentManagementEnabled = params.isDocumentManagementEnabled; } // Use PUT method with MSCRM.MergeLabels header as per Microsoft documentation await client.putMetadata(`EntityDefinitions(LogicalName='${params.logicalName}')`, updatedEntity, { 'MSCRM.MergeLabels': 'true' }); // Publish the changes as required by the API await client.callAction('PublishXml', { ParameterXml: `<importexportxml><entities><entity>${params.logicalName}</entity></entities></importexportxml>` }); return { content: [ { type: "text", text: `Successfully updated table '${params.logicalName}' and published changes.` } ] }; } catch (error) { return { content: [ { type: "text", text: `Error updating table: ${error instanceof Error ? error.message : 'Unknown error'}` } ], isError: true }; } }
- src/tools/table-tools.ts:198-215 (schema)Zod-based input schema defining parameters for updating table properties including logicalName (required), optional display names, description, and boolean flags for various table features.{ title: "Update Dataverse Table", description: "Updates the properties and configuration of an existing Dataverse table. Use this to modify table settings like display names, descriptions, or feature enablement (activities, notes, auditing, etc.). Changes are published automatically.", inputSchema: { logicalName: z.string().describe("Logical name of the table to update"), displayName: z.string().optional().describe("New display name for the table"), displayCollectionName: z.string().optional().describe("New display collection name for the table"), description: z.string().optional().describe("New description of the table"), hasActivities: z.boolean().optional().describe("Whether the table can have activities"), hasNotes: z.boolean().optional().describe("Whether the table can have notes"), isAuditEnabled: z.boolean().optional().describe("Whether auditing is enabled"), isDuplicateDetectionEnabled: z.boolean().optional().describe("Whether duplicate detection is enabled"), isValidForQueue: z.boolean().optional().describe("Whether records can be added to queues"), isConnectionsEnabled: z.boolean().optional().describe("Whether connections are enabled"), isMailMergeEnabled: z.boolean().optional().describe("Whether mail merge is enabled"), isDocumentManagementEnabled: z.boolean().optional().describe("Whether document management is enabled") } },
- src/tools/table-tools.ts:196-314 (registration)Registers the 'update_dataverse_table' tool on the MCP server within the updateTableTool export function, including schema and handler.server.registerTool( "update_dataverse_table", { title: "Update Dataverse Table", description: "Updates the properties and configuration of an existing Dataverse table. Use this to modify table settings like display names, descriptions, or feature enablement (activities, notes, auditing, etc.). Changes are published automatically.", inputSchema: { logicalName: z.string().describe("Logical name of the table to update"), displayName: z.string().optional().describe("New display name for the table"), displayCollectionName: z.string().optional().describe("New display collection name for the table"), description: z.string().optional().describe("New description of the table"), hasActivities: z.boolean().optional().describe("Whether the table can have activities"), hasNotes: z.boolean().optional().describe("Whether the table can have notes"), isAuditEnabled: z.boolean().optional().describe("Whether auditing is enabled"), isDuplicateDetectionEnabled: z.boolean().optional().describe("Whether duplicate detection is enabled"), isValidForQueue: z.boolean().optional().describe("Whether records can be added to queues"), isConnectionsEnabled: z.boolean().optional().describe("Whether connections are enabled"), isMailMergeEnabled: z.boolean().optional().describe("Whether mail merge is enabled"), isDocumentManagementEnabled: z.boolean().optional().describe("Whether document management is enabled") } }, async (params) => { try { // First, retrieve the current entity definition const currentEntity = await client.getMetadata<EntityMetadata>( `EntityDefinitions(LogicalName='${params.logicalName}')` ); // Create the updated entity definition by merging current with new values const updatedEntity: any = { ...currentEntity, "@odata.type": "Microsoft.Dynamics.CRM.EntityMetadata" }; // Update only the specified properties if (params.displayName) { updatedEntity.DisplayName = createLocalizedLabel(params.displayName); } if (params.displayCollectionName) { updatedEntity.DisplayCollectionName = createLocalizedLabel(params.displayCollectionName); } if (params.description) { updatedEntity.Description = createLocalizedLabel(params.description); } if (params.hasActivities !== undefined) { updatedEntity.HasActivities = params.hasActivities; } if (params.hasNotes !== undefined) { updatedEntity.HasNotes = params.hasNotes; } if (params.isAuditEnabled !== undefined) { updatedEntity.IsAuditEnabled = { Value: params.isAuditEnabled, CanBeChanged: true, ManagedPropertyLogicalName: "canmodifyauditsettings" }; } if (params.isDuplicateDetectionEnabled !== undefined) { updatedEntity.IsDuplicateDetectionEnabled = { Value: params.isDuplicateDetectionEnabled, CanBeChanged: true, ManagedPropertyLogicalName: "canmodifyduplicatedetectionsettings" }; } if (params.isValidForQueue !== undefined) { updatedEntity.IsValidForQueue = { Value: params.isValidForQueue, CanBeChanged: true, ManagedPropertyLogicalName: "canmodifyqueuesettings" }; } if (params.isConnectionsEnabled !== undefined) { updatedEntity.IsConnectionsEnabled = { Value: params.isConnectionsEnabled, CanBeChanged: true, ManagedPropertyLogicalName: "canmodifyconnectionsettings" }; } if (params.isMailMergeEnabled !== undefined) { updatedEntity.IsMailMergeEnabled = { Value: params.isMailMergeEnabled, CanBeChanged: true, ManagedPropertyLogicalName: "canmodifymailmergesettings" }; } if (params.isDocumentManagementEnabled !== undefined) { updatedEntity.IsDocumentManagementEnabled = params.isDocumentManagementEnabled; } // Use PUT method with MSCRM.MergeLabels header as per Microsoft documentation await client.putMetadata(`EntityDefinitions(LogicalName='${params.logicalName}')`, updatedEntity, { 'MSCRM.MergeLabels': 'true' }); // Publish the changes as required by the API await client.callAction('PublishXml', { ParameterXml: `<importexportxml><entities><entity>${params.logicalName}</entity></entities></importexportxml>` }); return { content: [ { type: "text", text: `Successfully updated table '${params.logicalName}' and published changes.` } ] }; } catch (error) { return { content: [ { type: "text", text: `Error updating table: ${error instanceof Error ? error.message : 'Unknown error'}` } ], isError: true }; } } );
- src/index.ts:141-141 (registration)Invokes updateTableTool to perform the actual registration of the tool during server initialization.updateTableTool(server, dataverseClient);
- src/tools/table-tools.ts:7-23 (helper)Utility function to create standardized LocalizedLabel objects used in updating DisplayName, DisplayCollectionName, and Description fields.function createLocalizedLabel(text: string, languageCode: number = 1033): LocalizedLabel { return { LocalizedLabels: [ { Label: text, LanguageCode: languageCode, IsManaged: false, MetadataId: "00000000-0000-0000-0000-000000000000" } ], UserLocalizedLabel: { Label: text, LanguageCode: languageCode, IsManaged: false, MetadataId: "00000000-0000-0000-0000-000000000000" } };