update_form_data
Modifies existing form data entries on the JianDaoYun MCP Server using app ID, form ID, and entry ID, with options to trigger automation and manage transactions.
Instructions
Update an existing form data entry
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| appId | Yes | The JianDaoYun application ID | |
| appKey | No | The JianDaoYun application key (API key) (optional, will use JIANDAOYUN_APP_KEY from environment if not provided) | |
| data | Yes | The data to update | |
| dataId | Yes | The data entry ID to update | |
| formId | Yes | The form ID (can be form ID or app ID) | |
| isStartTrigger | No | Whether to trigger automation | |
| transactionId | No | Optional transaction ID |
Implementation Reference
- src/index.ts:807-856 (handler)MCP tool handler for 'update_form_data': validates params, resolves form ID, creates JianDaoYunClient, calls updateFormData on it, and returns the result or enhanced error.case 'update_form_data': { const { formId, dataId, data, transactionId, isStartTrigger } = args as { formId: string; dataId: string; data: FormData; transactionId?: string; isStartTrigger?: boolean; }; const { appId, appKey, baseUrl } = getDefaultParams(args); // 验证必需参数 if (!appKey) { throw new Error('appKey is required. Please set JIANDAOYUN_APP_KEY in MCP server configuration.'); } if (!appId) { throw new Error('appId is required. Please provide it as parameter.'); } try { // 创建客户端实例 const jdyClient = new JianDaoYunClient({ appId, appKey, baseUrl }); const resolved = await resolveFormId(formId, appKey); const result = await jdyClient.updateFormData(resolved.formId, dataId, data, { transactionId, isStartTrigger, }); return { content: [ { type: 'text', text: JSON.stringify({ success: true, result, message: '数据更新成功', formUsed: resolved.formId, appId: resolved.appId || appId }, null, 2), }, ], }; } catch (error) { throw createEnhancedError(error, '更新表单数据'); } }
- src/index.ts:393-430 (registration)Tool registration in the tools array passed to server.setTools(), including name, description, and input schema definition.{ name: 'update_form_data', description: 'Update an existing form data entry', inputSchema: { type: 'object', properties: { appId: { type: 'string', description: 'The JianDaoYun application ID', }, appKey: { type: 'string', description: 'The JianDaoYun application key (API key) (optional, will use JIANDAOYUN_APP_KEY from environment if not provided)', }, formId: { type: 'string', description: 'The form ID (can be form ID or app ID)', }, dataId: { type: 'string', description: 'The data entry ID to update', }, data: { type: 'object', description: 'The data to update', }, transactionId: { type: 'string', description: 'Optional transaction ID', }, isStartTrigger: { type: 'boolean', description: 'Whether to trigger automation', }, }, required: ['appId', 'formId', 'dataId', 'data'], }, },
- src/index.ts:397-428 (schema)Input schema validation definition for the 'update_form_data' tool.type: 'object', properties: { appId: { type: 'string', description: 'The JianDaoYun application ID', }, appKey: { type: 'string', description: 'The JianDaoYun application key (API key) (optional, will use JIANDAOYUN_APP_KEY from environment if not provided)', }, formId: { type: 'string', description: 'The form ID (can be form ID or app ID)', }, dataId: { type: 'string', description: 'The data entry ID to update', }, data: { type: 'object', description: 'The data to update', }, transactionId: { type: 'string', description: 'Optional transaction ID', }, isStartTrigger: { type: 'boolean', description: 'Whether to trigger automation', }, }, required: ['appId', 'formId', 'dataId', 'data'],
- src/client.ts:264-294 (helper)Core helper method in JianDaoYunClient class that formats data and makes the API call to update form data in JianDaoYun.async updateFormData(formId: string, dataId: string, data: FormData, options?: { transactionId?: string; isStartTrigger?: boolean }): Promise<any> { try { const requestData: any = { app_id: this.config.appId, entry_id: formId, data_id: dataId, data: this.formatDataForSubmission(data) }; if (options?.transactionId) { requestData.transaction_id = options.transactionId; } if (options?.isStartTrigger !== undefined) { requestData.is_start_trigger = options.isStartTrigger; } const response = await this.axios.post<ApiResponse>('/v5/app/entry/data/update', requestData); if (response.data.code !== 0) { throw new Error(`Failed to update form data: ${response.data.msg}`); } return response.data.data; } catch (error) { if (axios.isAxiosError(error)) { throw new Error(`API request failed: ${error.response?.data?.msg || error.message}`); } throw error; } }