更新特定记录
目的
更新一个特定的实体或记录。
请求URL
https://www.zohoapis.com.cn/crm/v2/{module_api_name}/{record_id}
module_api_name - 模块的API名称
record_id - 记录的唯一ID
在获取特定记录中支持的模块在这里也支持。
请求方法
PUT
范围
scope=ZohoCRM.modules.all
(或)
scope=ZohoCRM.modules.{module_name}.{operation_type}
可能的模块名称 | 可能的操作类型 |
---|---|
线索,客户,联系人,商机,市场活动,任务,服务支持,事件,通话,解决方案,产品,供货商,价格表,报价单,销售订单,采购订单,发货单,自定义模块,备注和活动 | ALL - 完全访问记录 WRITE - 编辑模块中的记录 UPDATE - 更新模块中的记录 |
备注:
如果字段值长度大于为该字段定义的最大长度,将抛出错误。
如果在函数中使用API,并且字段值长度超过限制,则该函数将从API接收错误响应。例如:如果“文本字段”的最大长度定义为10,那么API中给出的值不能是“12345678901”,因为它有11个字符。
对于每个基于惟一字段的插入记录API调用,都会检查重复项。
每次API调用最多可以插入100条记录。
在输入中提供字段API名称以及要填充的相应值。
trigger输入可以是workflow,approval或blueprint。如果没有提到触发器,将执行与API相关的工作流、审批和蓝图。输入触发器值为[]就不执行工作流。
如果对一条记录的update API调用来自DRE(函数),由于在同一条记录的create / update上触发了工作流,那么无论触发器参数配置如何,工作流都不会单独执行。
包含子表单明细的记录可以使用记录API插入到CRM中。请参考子表单API了解有关在记录中添加子表单信息的更多信息。
请参考响应结构了解有关JSON键、值及其描述的详细信息。您还可以使用每个模块的示例响应作为输入,在相应模块中插入、更新或维护记录。
示例属性
属性 | 示例 |
---|---|
单行 | "Single_Line_1": "这是一个单行", |
多行 | "Multi_Line_1": "这是第一行 \n 这是第二行", |
邮箱 | "Email_1": "p.boyle@zylker.com", |
电话 | "Phone_1": "9900000000", |
选择列表 | "Picklist_1" : "In Progress", |
多选列表 | "Multi-Select_Picklist" : [ "{Option_1}", "{Option_2}", "{Option_3}" ], |
日期 | "Date_1": "2017-08-16", |
日期/时间 | "Date_Time": "2017-08-16T14:32:23+05:30", |
数字 | "Number_1": 575, |
货币 | "Currency_1": 250000, |
小数 | "Decimal_1": 250000.50, |
百分比 | ""Percent_1": 25, |
长整型 | "Long_Integer_1": "250000000000000", |
复选框 | "Checkbox_1": false, |
URL | URL_1": "https://www.zoho.com.cn/crm", |
查找 | "Lookup" : { "name" : "James" "id" : "425248000000104001" }, |
记录所有者 | "Owner": { "name" : "Patricia" "id": "425248000000104003" }, |
布局 | "Layout": { "name" : "Custom Layout 1" "id": "425248000000404433" }, |
示例请求
在这个请求中,"@updatelead.json"包含了示例输入数据。
在上面的示例中,将更新ID为"410888000000698006"的记录。
curl "https://www.zohoapis.com.cn/crm/v2/Leads/410888000000698006"
-X PUT
-d "@updatelead.json"
-H "Authorization: Zoho-oauthtoken 1000.8cb99dxxxxxxxxxxxxx9be93.9b8xxxxxxxxxxxxxxxf"
示例输入
{
"data": [
{
"Company": "Acme Inc",
"Last_Name": "Donelly",
"First_Name": "Jennifer",
"Email": "jennifer@acme.com",
"State": "Texas",
"Country": "United States"
}
],
"trigger": [
"approval"
]
}
示例响应
{
"data": [
{
"code": "SUCCESS",
"details": {
"created_time": "2016-08-09T16:27:05+05:30",
"modified_time": "2016-09-15T14:26:52+05:30",
"modified_by": {
"name": "Patricia Boyle",
"id": "410888000000086001"
},
"id": "410888000000698006",
"created_by": {
"name": "Patricia Boyle",
"id": "410888000000086001"
}
},
"message": "record updated",
"status": "success"
}
]
}
示例请求
ZCRMRecord record = ZCRMRecord.getInstance("Products",1234567l);// 包含记录ID的模块API名称
record.setFieldValue("Product_Name","name");// 字段API名称和要更新的值
ZCRMRecord lookup = ZCRMRecord.getInstance("Vendors",123456789l);// 供应商模块API名称及其记录ID
record.setFieldValue("Vendor_Name", lookup);
APIResponse response = record.update();
ZCRMRecord updatedRecord = (ZCRMRecord) response.getData();
String recStatus = response.getStatus(); // 检查记录的状态
示例输入
{
"data": [
{
"Company": "Acme Inc",
"Last_Name": "Donelly",
"First_Name": "Jennifer",
"Email": "jennifer@acme.com",
"State": "Texas",
"Country": "United States"
}
],
"trigger": [
"approval"
]
}
示例响应
{
"data": [
{
"code": "SUCCESS",
"details": {
"created_time": "2016-08-09T16:27:05+05:30",
"modified_time": "2016-09-15T14:26:52+05:30",
"modified_by": {
"name": "Patricia Boyle",
"id": "410888000000086001"
},
"id": "410888000000698006",
"created_by": {
"name": "Patricia Boyle",
"id": "410888000000086001"
}
},
"message": "record updated",
"status": "success"
}
]
}
示例请求
$zcrmRecordIns = ZCRMRecord::getInstance("Leads", 410405000001304021);
$zcrmRecordIns->setFieldValue("Product_Name", “iPhone 6s Plus”);
$apiResponse=$zcrmRecordIns->update();
示例输入
{
"data": [
{
"Company": "Acme Inc",
"Last_Name": "Donelly",
"First_Name": "Jennifer",
"Email": "jennifer@acme.com",
"State": "Texas",
"Country": "United States"
}
],
"trigger": [
"approval"
]
}
示例响应
{
"data": [
{
"code": "SUCCESS",
"details": {
"created_time": "2016-08-09T16:27:05+05:30",
"modified_time": "2016-09-15T14:26:52+05:30",
"modified_by": {
"name": "Patricia Boyle",
"id": "410888000000086001"
},
"id": "410888000000698006",
"created_by": {
"name": "Patricia Boyle",
"id": "410888000000086001"
}
},
"message": "record updated",
"status": "success"
}
]
}
示例请求
def update_record(self):
try:
record=ZCRMRecord.get_instance('Leads',1386586000001856002)#1386586000001856002 is leadid
record.set_field_value('Last_Name', 'Python')
record.set_field_value('Mobile', '9999999999')
record.set_field_value('Phone', '9999999998')
user=ZCRMUser.get_instance(1386586000000105001,'Python User1')
record.set_field_value('Email', 'support@zohocrm.com')
record.set_field_value('Owner',user)
resp=record.update()
print resp.status_code
print resp.code
print resp.details
print resp.message
print resp.status
except ZCRMException as ex:
print ex.status_code
print ex.error_message
print ex.error_code
print ex.error_details
print ex.error_content
示例输入
{
"data": [
{
"Company": "Acme Inc",
"Last_Name": "Donelly",
"First_Name": "Jennifer",
"Email": "jennifer@acme.com",
"State": "Texas",
"Country": "United States"
}
],
"trigger": [
"approval"
]
}
示例响应
{
"data": [
{
"code": "SUCCESS",
"details": {
"created_time": "2016-08-09T16:27:05+05:30",
"modified_time": "2016-09-15T14:26:52+05:30",
"modified_by": {
"name": "Patricia Boyle",
"id": "410888000000086001"
},
"id": "410888000000698006",
"created_by": {
"name": "Patricia Boyle",
"id": "410888000000086001"
}
},
"message": "record updated",
"status": "success"
}
]
}
示例请求:更新价格表记录
语法:
zoho.crm.update(<module String>,<recordID Long>,<dataMap Map>,<optionalDataMap Map>,<connectionName String>,<userAccess Boolean>);
mandatory : module,recordID,dataMap
示例请求:
resp = zoho.crm.update("Price_Books", "7000000037030", {"Owner": {"id": "7000000031553"},"Active": true,"Pricing_Details": [{"to_range": 5,"discount": 0,"from_range": 1},{"to_range": 11,"discount": 1,"from_range": 6},{"to_range": 17,"discount": 2,"from_range": 12},{"to_range": 23,"discount": 3,"from_range": 18},{"to_range": 29,"discount": 4,"from_range": 24}],"Pricing_Model": "Differential","Description": "Design your own layouts that align your business processes precisely. Assign them to profiles appropriately.","Price_Book_Name": "Price_Book_Name oops1 updated twice"});
示例输入
{
"data": [
{
"Company": "Acme Inc",
"Last_Name": "Donelly",
"First_Name": "Jennifer",
"Email": "jennifer@acme.com",
"State": "Texas",
"Country": "United States"
}
],
"trigger": [
"approval"
]
}
示例响应
{
"data": [
{
"code": "SUCCESS",
"details": {
"created_time": "2016-08-09T16:27:05+05:30",
"modified_time": "2016-09-15T14:26:52+05:30",
"modified_by": {
"name": "Patricia Boyle",
"id": "410888000000086001"
},
"id": "410888000000698006",
"created_by": {
"name": "Patricia Boyle",
"id": "410888000000086001"
}
},
"message": "record updated",
"status": "success"
}
]
}
示例请求
ZCRMRecord recordIns = ZCRMRecord.GetInstance("Products", 3372164000001633018);// 包含记录ID的模块API名称
recordIns.SetFieldValue("Product_Name", "name");// 字段API名称和要更新的值
ZCRMRecord lookup = ZCRMRecord.GetInstance("Vendors", 3372164000000531084);//供应商模块API名称及其记录ID
recordIns.SetFieldValue("Vendor_Name", lookup);
APIResponse response = recordIns.Update();
ZCRMRecord updatedRecord = (ZCRMRecord)response.Data;
示例输入
{
"data": [
{
"Company": "Acme Inc",
"Last_Name": "Donelly",
"First_Name": "Jennifer",
"Email": "jennifer@acme.com",
"State": "Texas",
"Country": "United States"
}
],
"trigger": [
"approval"
]
}
示例响应
{
"data": [
{
"code": "SUCCESS",
"details": {
"created_time": "2016-08-09T16:27:05+05:30",
"modified_time": "2016-09-15T14:26:52+05:30",
"modified_by": {
"name": "Patricia Boyle",
"id": "410888000000086001"
},
"id": "410888000000698006",
"created_by": {
"name": "Patricia Boyle",
"id": "410888000000086001"
}
},
"message": "record updated",
"status": "success"
}
]
}