dynamics_register_plugin_step
Register a new plugin step in Dynamics CRM to extend functionality by defining execution triggers, stages, and target entities for custom business logic.
Instructions
Registra um novo step de plugin no Dynamics CRM
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| pluginTypeId | Yes | ID do tipo de plugin | |
| message | Yes | Mensagem do SDK (ex: Create, Update) | |
| entityLogicalName | Yes | Nome lógico da entidade | |
| stage | Yes | Estágio: 10=PreValidation, 20=PreOperation, 40=PostOperation | |
| executionMode | No | 0=Synchronous, 1=Asynchronous | |
| filteringAttributes | No | Atributos de filtragem | |
| name | Yes | Nome do step | |
| rank | No | Ordem de execução |
Implementation Reference
- src/tools/plugins/index.ts:194-233 (handler)Implementation of the dynamics_register_plugin_step tool handler.
server.tool( "dynamics_register_plugin_step", "Registra um novo step de plugin no Dynamics CRM", RegisterPluginStepSchema.shape, async (params: z.infer<typeof RegisterPluginStepSchema>) => { const stepData = { name: params.name, stage: params.stage, mode: params.executionMode, rank: params.rank, "plugintypeid@odata.bind": `/plugintypes(${params.pluginTypeId})`, "sdkmessageid@odata.bind": `/sdkmessages?$filter=name eq '${params.message}'`, filteringattributes: params.filteringAttributes || null, supporteddeployment: 0, // Server only }; // Get the message filter for the entity const messageFilter = await client.list("sdkmessagefilters", { select: ["sdkmessagefilterid"], filter: `primaryobjecttypecode eq '${params.entityLogicalName}' and sdkmessageid/name eq '${params.message}'`, top: 1, }); if (messageFilter.value.length > 0) { const filterId = (messageFilter.value[0] as Record<string, unknown>).sdkmessagefilterid; (stepData as Record<string, unknown>)["sdkmessagefilterid@odata.bind"] = `/sdkmessagefilters(${filterId})`; } const result = await client.create("sdkmessageprocessingsteps", stepData); return { content: [ { type: "text" as const, text: `Step registrado com sucesso!\nID: ${result.entityId}\nNome: ${params.name}\nMensagem: ${params.message}\nEntidade: ${params.entityLogicalName}\nEstágio: ${params.stage}`, }, ], }; } ); - src/tools/plugins/index.ts:29-38 (schema)Input schema for dynamics_register_plugin_step tool.
export const RegisterPluginStepSchema = z.object({ pluginTypeId: z.string().describe("ID do tipo de plugin"), message: z.string().describe("Mensagem do SDK (ex: Create, Update)"), entityLogicalName: z.string().describe("Nome lógico da entidade"), stage: z.number().describe("Estágio: 10=PreValidation, 20=PreOperation, 40=PostOperation"), executionMode: z.number().default(0).describe("0=Synchronous, 1=Asynchronous"), filteringAttributes: z.string().optional().describe("Atributos de filtragem"), name: z.string().describe("Nome do step"), rank: z.number().default(1).describe("Ordem de execução"), }); - src/tools/plugins/index.ts:70-73 (registration)Registration function that defines all plugin tools, including dynamics_register_plugin_step.
export function registerPluginTools( server: { tool: Function }, client: DataverseClient ) {