b24_crm_update
Update fields of an existing CRM record by providing its ID and the fields to modify.
Instructions
Actualiza campos de un registro CRM existente.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| entity | No | ||
| entity_type_id | No | ||
| id | Yes | ||
| fields | Yes | Campos a actualizar | |
| params | No | ||
| webhook_url | No |
Implementation Reference
- index.js:121-123 (registration)Registration of the 'b24_crm_update' tool with description, schema, and handler
server.tool('b24_crm_update', 'Actualiza campos de un registro CRM existente.', crmUpdateSchema.shape, wrap(crmUpdate)); - src/tools/crm.js:89-96 (schema)Zod schema defining input validation for the update tool: entity/entity_type_id, id, fields to update, optional params and webhook_url
export const crmUpdateSchema = z.object({ entity: z.string().optional(), entity_type_id: z.number().int().optional(), id: z.union([z.string(), z.number()]), fields: z.record(z.any()).describe('Campos a actualizar'), params: z.record(z.any()).optional(), webhook_url: z.string().url().optional(), }); - src/tools/crm.js:98-103 (handler)Handler function that executes the CRM update: resolves webhook, determines API method, calls Bitrix24 REST API, returns result
export async function crmUpdate({ entity, entity_type_id, id, fields, params = {}, webhook_url }) { const client = new Bitrix24Client(resolveWebhook(webhook_url)); const { base, extra } = resolveMethod(entity, entity_type_id); await client.call(`${base}.update`, { id, fields, params, ...extra }); return { entity: entity || `SPA_${entity_type_id}`, portal: client.portal, updated_id: id, success: true }; } - src/tools/crm.js:18-23 (helper)Helper function that maps entity name to Bitrix24 REST API method base (e.g., deal→crm.deal, SPA→crm.item with entityTypeId)
function resolveMethod(entity, entityTypeId) { if (entityTypeId) return { base: 'crm.item', extra: { entityTypeId } }; const base = ENTITY_METHOD[entity?.toLowerCase()]; if (!base) throw new Error(`Entidad desconocida: "${entity}". Usá deal, contact, company, lead, quote, invoice, o pasá entityTypeId para SPA.`); return { base, extra: {} }; }