更新相关的记录
目的
更新记录之间的关系。
请求URL
https://www.zohoapis.com.cn/crm/v2/{module_api_name}/{record_id}/{related_list_api_name}/{related_record_id}
module_api_name - 模块的API名称
record_id - 记录的唯一ID
related_list_api_name - 相关列表的API名称。要获取相关列表的API名称,请查看相关列表元数据
related_record_id - 相关记录的唯一ID
支持的关系 |
---|
市场活动 - 到 - 线索,联系人 产品 - 到 - 线索,客户 联系人,商机,价格表 |
请求方法
PUT
范围
scope=ZohoCRM.modules.all
(或)
scope=ZohoCRM.modules.{module_name}.{operation_type}
可能的模块名称 | 可能的操作类型 |
---|---|
线索,商机,联系人,客户,产品,市场活动和价格表 | ALL - 完全访问记录 WRITE - 编辑相关的记录 DELETE - 删除相关的记录 |
备注:
在添加其他模块之间的关系时,必须发送示例数据。
示例请求:添加线索和市场活动之间的关系
在这个请求中,ID为1000013559的市场活动与ID为1000017063的线索相关联。
curl "https://www.zohoapis.com.cn/crm/v2/Leads/1000017063/Campaigns/1000013559"
-X PUT
-d @updaterelatedlead.json
-H "Authorization: Zoho-oauthtoken 1000.8cb99dxxxxxxxxxxxxx9be93.9b8xxxxxxxxxxxxxxxf"
示例输入
{
"data": [
{
"Member_Status": "active"
}
]
}
示例请求:添加联系人和商机之间的关系
在这个请求中,ID为1000013559的商机与ID为1000017063的联系人相关联。
curl "https://www.zohoapis.com.cn/crm/v2/Contacts/1000017063/Deals/1000013559"
-X PUT
-d @updaterelatedlead.json
-H "Authorization: Zoho-oauthtoken 1000.8cb99dxxxxxxxxxxxxx9be93.9b8xxxxxxxxxxxxxxxf"
示例输入
{
"data": [
{
"Contact_Role": "1000000024229"
}
]
}
示例请求:添加产品和价格表之间的关系
在这个请求中,ID为 1000013559的价格表与ID为1000017063的产品相关联。
curl "https://www.zohoapis.com.cn/crm/v2/Products/1000017063/Pricebooks/1000013559"
-X PUT
-d @updaterelatedlead.json
-H "Authorization: Zoho-oauthtoken 1000.8cb99dxxxxxxxxxxxxx9be93.9b8xxxxxxxxxxxxxxxf"
示例输入
{
"data": [
{
"list_price": 50.56
}
]
}
示例响应
{
"data": [
{
"code": "SUCCESS",
"details": {
"id": "4000000039247"
},
"message": "relation added",
"status": "success"
}
]
}
示例请求:添加线索和市场活动之间的关系
在这个请求中,ID为1234567l的线索与ID为963258l的市场活动相关联。
ZCRMRecord record = ZCRMRecord.getInstance("Leads", 1234567l);//模块API名称和记录ID
ZCRMJunctionRecord relatedRecord = ZCRMJunctionRecord.getInstance("Campaigns", 963258l);
relatedRecord.setRelatedData("Status", "active");
APIResponse response = record.addRelation(relatedRecord);
String recStatus = response.getStatus(); //检查更新关系的状态
示例输入
{
"data": [
{
"Member_Status": "active"
}
]
}
示例请求:添加产品和价格表之间的关系
在这个请求中,ID为880428000000261025l的价格表与ID为880428000003772042l的产品相关联。
ZCRMRecord record = ZCRMRecord.getInstance("Products",880428000003772042l);//模块API名称和记录ID
ZCRMJunctionRecord relatedRecord = ZCRMJunctionRecord.getInstance("Price_Books", 880428000000261025l);
relatedRecord.setRelatedData("list_price", 50.56);
APIResponse response = record.addRelation(relatedRecord);
String recStatus = response.getStatus(); //检查更新关系的状态
示例输入
{
"data": [
{
"list_price": 50.56
}
]
}
示例响应
{
"data": [
{
"code": "SUCCESS",
"details": {
"id": "4000000039247"
},
"message": "relation added",
"status": "success"
}
]
}
示例请求:添加产品和价格表之间的关系
try{
$parentRecord=ZCRMRecord::getInstance("Products", 410405000001446001);
$junctionRecord=ZCRMJunctionRecord::getInstance("Price_Books",
410405000001404743);
$junctionRecord->setRelatedData("list_price", 140);
$responseIns=$parentRecord->addRelation($junctionRecord);
echo "HTTP Code:".$responseIns->getHttpStatusCode();
echo "Message:".$responseIns->getMessage();
echo "Code:".$responseIns->getCode();
echo "Details:".$responseIns->getDetails()['id'];
}catch (ZCRMException $e)
{
echo $e->getCode();
echo $e->getMessage();
}
示例输入
{
"data": [
{
"list_price": 50.56
}
]
}
示例响应
{
"data": [
{
"code": "SUCCESS",
"details": {
"id": "4000000039247"
},
"message": "relation added",
"status": "success"
}
]
}
示例请求:添加线索和产品之间的关系
def add_relation(self):
try:
record=ZCRMRecord.get_instance('Leads',3652397000000190373) #module API Name, entityId
junction_record=ZCRMJunctionRecord.get_instance("Products", 3652397000000341056) #module API Name, entityId
resp=record.add_relation(junction_record)
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": [
{
"Product_Name": MyProduct
}
]
}
示例响应
{
"data": [
{
"code": "SUCCESS",
"details": {
"id": "4000000039247"
},
"message": "relation added",
"status": "success"
}
]
}
示例请求
语法:
zoho.crm.updateRelatedRecord(<module String>,<recordID Long>,<parentModuleName String>,<parentRecordId Long>,<dataMap Map>,<connectionName String>,<userAccess Boolean>);
mandatory : module,recordID,parentModuleName,parentRecordId,dataMap
示例请求:
resp = zoho.crm.updateRelatedRecord("Related_List_Name_2","7000000037119","Leads","7000000037002", Map());
示例响应
{
"data": [
{
"code": "SUCCESS",
"details": {
"id": "4000000039247"
},
"message": "relation added",
"status": "success"
}
]
}
示例请求
ZCRMRecord recordIns = ZCRMRecord.GetInstance("Leads", 337216400000); //模块API名称和记录ID
ZCRMJunctionRecord relatedRecord = ZCRMJunctionRecord.GetInstance("Campaigns", 33721640000001); //包含相关列表记录ID的相关列表API名称
relatedRecord.SetRelatedDetails("Status", "active");
APIResponse response = recordIns.AddRelation(relatedRecord);
String recStatus = response.Status; //检查更新关系的状态
//在上面的示例中,ID为337216400000的线索与ID为33721640000001的市场活动相关联。
示例输入
{
"data": [
{
"Member_Status": "active"
}
]
}
示例响应
{
"data": [
{
"code": "SUCCESS",
"details": {
"id": "4000000039247"
},
"message": "relation added",
"status": "success"
}
]
}