更新记录
目的
更新模块中现有的实体。
请求URL
https://www.zohoapis.com.cn/crm/v2/{module_api_name}
module_api_name - 模块的API名称
在获取记录列表中支持的模块在这里也支持。
请求方法
PUT
范围
scope=ZohoCRM.modules.all
(或)
scope=ZohoCRM.modules.{module_name}.{operation_type}
可能的模块名称 | 可能的操作类型 |
---|---|
线索,客户,联系人,商机,市场活动,任务,服务支持,事件,通话,解决方案,产品,供货商,价格表,报价单,销售订单,采购订单,发货单,自定义模块和备注 | ALL - 完全访问记录 WRITE - 编辑模块中的记录 UPDATE - 更新模块中的记录 |
可能的错误
HTTP状态 | 错误码 | 消息 | 原因 |
---|---|---|---|
400 | INVALID_MODULE | The module name given seems to be invalid | 无效的模块名称或没有模块权限,或者模块可能已从已组织的模块中删除 |
400 | INVALID_MODULE | The given module is not supported in API | 当前API不支持文档和项目等模块。(一旦支持了这些模块,就不会显示此错误。) |
备注:
如果字段值长度大于为该字段定义的最大长度,将抛出错误。
如果在函数中使用API,并且字段值长度超过限制,则该函数将从API接收错误响应。例如:如果“文本字段”的最大长度定义为10,那么API中给出的值不能是“12345678901”,因为它有11个字符。
对于每个基于惟一字段的插入记录API调用,都会检查重复项。
每次API调用最多可以插入100条记录。
在输入中提供字段API名称以及要填充的相应值。
trigger输入可以是workflow,approval或blueprint。如果没有提到触发器,将执行与API相关的工作流、审批和蓝图。输入触发器的值为[] 将不执行工作流。
包含子表单明细的记录可以使用记录API插入CRM。请参考子表单API 了解有关在记录中添加子表单明细的更多信息
$approved key用于设置要在审批模式下创建的记录。它主要用于从webforms获取线索和联系人。
如果对一条记录的更新API调用来自DRE(函数),由于在同一条记录的创建/更新上触发了工作流,那么无论触发器参数配置如何,工作流都不会单独执行。
参考响应结构了解有关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" 包含了示例输入。
curl "https://www.zohoapis.com.cn/crm/v2/Leads"
-X PUT
-d "@updatelead.json"
-H "Authorization: Zoho-oauthtoken 1000.8cb99dxxxxxxxxxxxxx9be93.9b8xxxxxxxxxxxxxxxf"
示例输入
{
"data": [
{
"id": "4108880000478060",
"Company": "Zylker",
"Subform_1": [
{
"$approval": {
"delegate": false,
"approve": false,
"reject": false,
"resubmit": false
},
"Owner": {
"name": "Chakra",
"id": "2883756000000133013"
},
"$currency_symbol": "$",
"Quantity": 1500,
"Name": "3",
"Name_of_the_product": "Bandages",
"Vendor_Email": "d.collins@ebspharma.com",
"Price": 15,
"id": "2883756000000458386"
}
],
"Last_Name": "Peterson"
}
],
"trigger": [
"approval"
]
}
示例响应
{
"data": [
{
"message": "record updated",
"details": {
"created_by": {
"id": "4108880000086001",
"name": "Patricia Boyle"
},
"id": "4108880000478060",
"modified_by": {
"id": "4108880000086001",
"name": "Patricia Boyle"
},
"modified_time": "2016-04-28T17:59:21+05:30",
"created_time": "2016-04-28T17:59:21+05:30"
},
"status": "success",
"code": "SUCCESS"
}
]
}
示例请求
List<Long> entityIDs = new ArrayList<>();// 记录ID列表
entityIDs.add(426000621092l);
entityIDs.add(426859000010l);
ZCRMModule module = ZCRMModule.getInstance("Products");//模块API名称
BulkAPIResponse response = module.updateRecords(entityIDs,"Product_Name","massUpdate");//字段API名称及其要更新的值
List<ZCRMRecord> updatedRecords = (List<ZCRMRecord>) response.getData();
List<BulkAPIResponse.EntityResponse> entityResponses = response.getEntityResponses();// 检查请求的状态
String rec1Status = entityResponses.get(0).getStatus();//检查记录1的状态
String rec2Status = entityResponses.get(1).getStatus();//检查记录2的状态
示例输入
{
"data": [
{
"id": "4108880000478060",
"Company": "Zylker",
"Subform_1": [
{
"$approval": {
"delegate": false,
"approve": false,
"reject": false,
"resubmit": false
},
"Owner": {
"name": "Chakra",
"id": "2883756000000133013"
},
"$currency_symbol": "$",
"Quantity": 1500,
"Name": "3",
"Name_of_the_product": "Bandages",
"Vendor_Email": "d.collins@ebspharma.com",
"Price": 15,
"id": "2883756000000458386"
}
],
"Last_Name": "Peterson"
}
],
"trigger": [
"approval"
]
}
示例响应
{
"data": [
{
"message": "record updated",
"details": {
"created_by": {
"id": "4108880000086001",
"name": "Patricia Boyle"
},
"id": "4108880000478060",
"modified_by": {
"id": "4108880000086001",
"name": "Patricia Boyle"
},
"modified_time": "2016-04-28T17:59:21+05:30",
"created_time": "2016-04-28T17:59:21+05:30"
},
"status": "success",
"code": "SUCCESS"
}
]
}
示例请求
$idList=array(410405000001076001,410405000001021027,410405000000497012);
$zcrmModuleIns = ZCRMModule::getInstance("Contacts");
$bulkAPIResponse=$zcrmModuleIns->updateRecords($idList,"Account_Name","NewAccount");
$entityResponses = $bulkAPIResponse->getEntityResponses();
foreach($entityResponses as $entityResponse)
{
if("success"==$entityResponse->getStatus())
{
echo "Status:".$entityResponse->getStatus();
echo "Message:".$entityResponse->getMessage();
echo "Code:".$entityResponse->getCode();
$recordIns=$entityResponse->getData();
echo "EntityID:".$recordIns->getEntityId();
echo "moduleAPIName:".$recordIns->getModuleAPIName();
….
}
}
示例输入
{
"data": [
{
"id": "4108880000478060",
"Company": "Zylker",
"Subform_1": [
{
"$approval": {
"delegate": false,
"approve": false,
"reject": false,
"resubmit": false
},
"Owner": {
"name": "Chakra",
"id": "2883756000000133013"
},
"$currency_symbol": "$",
"Quantity": 1500,
"Name": "3",
"Name_of_the_product": "Bandages",
"Vendor_Email": "d.collins@ebspharma.com",
"Price": 15,
"id": "2883756000000458386"
}
],
"Last_Name": "Peterson"
}
],
"trigger": [
"approval"
]
}
示例响应
{
"data": [
{
"message": "record updated",
"details": {
"created_by": {
"id": "4108880000086001",
"name": "Patricia Boyle"
},
"id": "4108880000478060",
"modified_by": {
"id": "4108880000086001",
"name": "Patricia Boyle"
},
"modified_time": "2016-04-28T17:59:21+05:30",
"created_time": "2016-04-28T17:59:21+05:30"
},
"status": "success",
"code": "SUCCESS"
}
]
}
示例请求
def update_records(self):
try:
module_ins=ZCRMModule.get_instance('Invoices') #module API Name
entityid_list=[440872000000280035,440872000000278029,440872000000278028]
bulk_resp=module_ins.update_records(entityid_list, 'Status', 'Created')
print bulk_resp.status_code
entity_responses=bulk_resp.bulk_entity_response
for entity_response in entity_responses:
print entity_response.details
print entity_response.status
print entity_response.message
print entity_response.code
print entity_response.data.entity_id
print entity_response.data.created_by.id
print entity_response.data.created_time
print entity_response.data.modified_by.id
print "\n\n"
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": [
{
"id": "4108880000478060",
"Company": "Zylker",
"Subform_1": [
{
"$approval": {
"delegate": false,
"approve": false,
"reject": false,
"resubmit": false
},
"Owner": {
"name": "Chakra",
"id": "2883756000000133013"
},
"$currency_symbol": "$",
"Quantity": 1500,
"Name": "3",
"Name_of_the_product": "Bandages",
"Vendor_Email": "d.collins@ebspharma.com",
"Price": 15,
"id": "2883756000000458386"
}
],
"Last_Name": "Peterson"
}
],
"trigger": [
"approval"
]
}
示例响应
{
"data": [
{
"message": "record updated",
"details": {
"created_by": {
"id": "4108880000086001",
"name": "Patricia Boyle"
},
"id": "4108880000478060",
"modified_by": {
"id": "4108880000086001",
"name": "Patricia Boyle"
},
"modified_time": "2016-04-28T17:59:21+05:30",
"created_time": "2016-04-28T17:59:21+05:30"
},
"status": "success",
"code": "SUCCESS"
}
]
}
示例请求:更新价格表记录
语法:
zoho.crm.bulkUpdate(<module String>,<dataList List>,<optionalDataMap Map>,<connectionName String>,<userAccess Boolean>);
mandatory : module,dataList
示例请求:
resp = zoho.crm.bulkUpdate("Price_Books", [{"Owner": {"id": "7000000031553"},"id":"7000000037030","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"},{"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", "id":"7000000037031","Description": "Design your own layouts that align your business processes precisely. Assign them to profiles appropriately.","Price_Book_Name": "Price_Book_Name oops2 updated"}]);
示例输入
{
"data": [
{
"id": "4108880000478060",
"Company": "Zylker",
"Subform_1": [
{
"$approval": {
"delegate": false,
"approve": false,
"reject": false,
"resubmit": false
},
"Owner": {
"name": "Chakra",
"id": "2883756000000133013"
},
"$currency_symbol": "$",
"Quantity": 1500,
"Name": "3",
"Name_of_the_product": "Bandages",
"Vendor_Email": "d.collins@ebspharma.com",
"Price": 15,
"id": "2883756000000458386"
}
],
"Last_Name": "Peterson"
}
],
"trigger": [
"approval"
]
}
示例响应
{
"data": [
{
"message": "record updated",
"details": {
"created_by": {
"id": "4108880000086001",
"name": "Patricia Boyle"
},
"id": "4108880000478060",
"modified_by": {
"id": "4108880000086001",
"name": "Patricia Boyle"
},
"modified_time": "2016-04-28T17:59:21+05:30",
"created_time": "2016-04-28T17:59:21+05:30"
},
"status": "success",
"code": "SUCCESS"
}
]
}
示例请求
List<ZCRMRecord> records = new List<ZCRMRecord>();
ZCRMRecord record1 = new ZCRMRecord("Leads"); //模块API名称
record1.SetFieldValue("Company", "Zylker");
record1.SetFieldValue("First_name", "Daly");
record1.SetFieldValue("Last_Name", "Paul");
record1.SetFieldValue("Email", "p.daly@zylker.com");
record1.SetFieldValue("State", "Texas");
ZCRMRecord record2 = new ZCRMRecord("Leads"); //模块API名称
record2.SetFieldValue("Company", "ekhrj");
record2.SetFieldValue("First_name", "John");
record2.SetFieldValue("Last_Name", "smith");
record2.SetFieldValue("Email", "john.a@ekhrj.com");
record2.SetFieldValue("State", "Texas");
records.Add(record1);
records.Add(record2);
ZCRMModule moduleIns = ZCRMModule.GetInstance("Leads"); //模块API名称
BulkAPIResponse<ZCRMRecord> response = moduleIns.UpsertRecords(records); //records - 包含upsert所需数据的ZCRMRecord实例列表。
List<ZCRMRecord> upsertedRecords = response.BulkData; //upsertedRecords - ZCRMRecord实例的列表
List<EntityResponse> entityResponses = response.BulkEntitiesResponse; //entityResponses - EntityResponses实例的列表
示例输入
{
"data": [
{
"Company": "Zylker",
"Last_Name": "Daly",
"First_Name": "Paul",
"Subform_1": [
{
"$approval": {
"delegate": false,
"approve": false,
"reject": false,
"resubmit": false
},
"Owner": {
"name": "Patricia Boyle",
"id": "2883756000000133013"
},
"$currency_symbol": "$",
"Quantity": 1500,
"Name": "3",
"Name_of_the_product": "Bandages",
"Vendor_Email": "d.collins@ebspharma.com",
"Price": 15,
"id": "2883756000000458386"
}
],
"Email": "p.daly@zylker.com",
"State": "Texas"
},
{
"Company": "Villa Margarita",
"Last_Name": "Dolan",
"First_Name": "Brian",
"Email": "brian@villa.com",
"State": "Texas"
}
],
"trigger": [
"approval"
]
}
示例响应
{
"data": [
{
"message": "record updated",
"details": {
"created_by": {
"id": "4108880000086001",
"name": "Patricia Boyle"
},
"id": "410888000000478065",
"modified_by": {
"id": "4108880000086001",
"name": "Patricia Boyle"
},
"modified_time": "2016-04-28T17:59:21+05:30",
"created_time": "2016-04-28T17:59:21+05:30"
},
"status": "success",
"duplicate_field": "Email",
"action": "update",
"code": "SUCCESS"
},
{
"message": "record updated",
"details": {
"created_by": {
"id": "4108880000086001",
"name": "Patricia Boyle"
},
"id": "4108880000478066",
"modified_by": {
"id": "4108880000086001",
"name": "Patricia Boyle"
},
"modified_time": "2016-04-28T17:59:21+05:30",
"created_time": "2016-04-28T17:59:21+05:30"
},
"status": "success",
"duplicate_field": "Email",
"action": "update",
"code": "SUCCESS"
}
]
}