dynamics_get_workflow_performance
Analyze workflow and automated process performance and status in Dynamics CRM to monitor execution, identify issues, and optimize business automation.
Instructions
Analisa performance e status de workflows e processos automáticos
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| top | No | ||
| statusFilter | No | all |
Implementation Reference
- src/tools/telemetry/index.ts:142-185 (handler)The handler for "dynamics_get_workflow_performance" queries 'asyncoperations' in Dynamics to provide performance and status summary of workflows.
server.tool( "dynamics_get_workflow_performance", "Analisa performance e status de workflows e processos automáticos", GetWorkflowPerformanceSchema.shape, async (params: z.infer<typeof GetWorkflowPerformanceSchema>) => { const filters: string[] = []; if (params.statusFilter !== "all") { const statusCode = WORKFLOW_STATUS[params.statusFilter]; if (statusCode !== undefined) { filters.push(`statuscode eq ${statusCode}`); } } const result = await client.list("asyncoperations", { select: [ "asyncoperationid", "name", "operationtype", "statuscode", "startedon", "completedon", "executiontimespan", "retrycount", "friendlymessage", "message", "primaryentitytype", "postponeuntil", "recurrencepattern", ], filter: filters.length > 0 ? filters.join(" and ") : undefined, orderby: "createdon desc", top: params.top, }); const jobs = result.value as Array<Record<string, unknown>>; const statusSummary: Record<string, number> = {}; for (const job of jobs) { const statusName = SYSTEM_JOB_STATUS[job.statuscode as number] || `Unknown (${job.statuscode})`; statusSummary[statusName] = (statusSummary[statusName] || 0) + 1; } const failedJobs = jobs.filter((j) => j.statuscode === 31); return { content: [ { type: "text" as const, text: `## Performance de Workflows/Processos\n\n**Resumo de Status:**\n${Object.entries(statusSummary).map(([status, count]) => `- ${status}: ${count}`).join("\n")}\n\n**Jobs com Falha:** ${failedJobs.length}\n${failedJobs.slice(0, 5).map((j) => `- **${j.name}**: ${j.friendlymessage || j.message || "Sem mensagem"}`).join("\n")}\n\n**Detalhes:**\n${JSON.stringify(jobs.slice(0, 10), null, 2)}`, }, ], }; } ); - src/tools/telemetry/index.ts:17-20 (schema)Input validation schema for the workflow performance tool.
export const GetWorkflowPerformanceSchema = z.object({ top: z.number().default(20), statusFilter: z.enum(["all", "succeeded", "failed", "waiting", "suspended", "cancelled"]).default("all"), }); - src/tools/telemetry/index.ts:80-83 (registration)Registration function that takes the server instance and registers the tools including dynamics_get_workflow_performance.
export function registerTelemetryTools( server: { tool: Function }, client: DataverseClient ) {