Deluge函数中存储zoho.currenttime到DateTime字段时遇无效数据错误
问题解决:Zoho CRM DateTime字段数据格式错误
错误原因
Zoho CRM的datetime类型字段仅接受ISO 8601标准格式的时间字符串(例如2023-03-14T13:01:57Z),而你使用zoho.currenttime()获取的是本地化格式(14-Mar-2023 13:01:57),这种格式不被CRM API识别,因此触发INVALID_DATA错误。
解决方案
有两种简单的方式获取符合要求的时间格式:
方式1:直接使用zoho.currenttimeiso函数
这个函数会直接返回ISO 8601格式的当前时间,无需额外转换,是最简便的方案:
// 获取符合CRM要求的ISO格式时间 send_datetime = zoho.currenttimeiso;
方式2:用formatdate转换zoho.currenttime的结果
如果你一定要保留zoho.currenttime的使用,可以通过formatdate函数将其转换为ISO格式:
current_time = zoho.currenttime; // 转换为ISO 8601格式 send_datetime = formatdate(current_time, "yyyy-MM-dd'T'HH:mm:ss'Z'");
完整示例代码
// 构造Request_Log记录数据 request_log = Map(); // 赋值正确格式的时间戳 request_log.put("Send_Date_Time", zoho.currenttimeiso); // 添加其他字段(示例) request_log.put("API_Response", "响应内容"); request_log.put("Request_URL", "https://api.example.com"); // 创建CRM记录 create_response = zoho.crm.createRecord("Request_Log", request_log); info create_response;
内容的提问来源于stack exchange,提问作者markwilland
相关产品推荐
相关产品推荐

