Update Related Records

Purpose

To update the relation between the records.

Request URL

https://www.zohoapis.com/crm/v2/{module_api_name}/{record_id}/{related_list_api_name}/{related_record_id}

module_api_name - The API name of the module

record_id - Unique ID of the record

related_list_api_name - The API name of the related list. To get the API name of the related list, see Related Lists Meta Data

related_record_id - Unique ID of the related record

Supported relations
Campaigns - to - Leads, Contacts

Products - to - Leads, Accounts,
Contacts, Potentials, Price Books

Request Method

PUT

Scope

scope=ZohoCRM.modules.all
(or)
scope=ZohoCRM.modules.{module_name}.{operation_type}


Possible module namesPossible operation types
leads, deals, contacts, accounts, products, campaigns, and pricebooksALL - Full access to records
WRITE - Edit related records
DELETE - Delete related records
Note
  • It is mandatory to send the sample data while adding relation between other modules.

  • To relate multiple records of a module to the parent module, you must pass individual JSON objects for each related record as shown in the example.

  • You can update a maximum of 100 related records per API call.

Sample Request

Copiedcurl "https://www.zohoapis.com/crm/v2/Leads/3652397000001829002/Campaigns"
-X PUT
-d @updaterelatedlead.json
-H "Authorization: Zoho-oauthtoken 1000.8cb99dxxxxxxxxxxxxx9be93.9b8xxxxxxxxxxxxxxxf"
CopiedZCRMRecord record = ZCRMRecord.getInstance("Leads", 1234567l);//module api name with record id
ZCRMJunctionRecord relatedRecord = ZCRMJunctionRecord.getInstance("Campaigns", 963258l);
relatedRecord.setRelatedData("Status", "active");
APIResponse response = record.addRelation(relatedRecord);
String recStatus = response.getStatus(); //check status of the update relation
Copiedtry{
$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();
}
Copied    def add_relation(self):
        try:
            record = ZCRMRecord.get_instance('Leads', 3719520000000323002)  # module API Name, entityId
            junction_record = ZCRMJunctionRecord.get_instance("Products",3719520000000450002)  # 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)
CopiedSyntax:
zoho.crm.updateRelatedRecord(<module String>,<recordID Long>,<parentModuleName String>,<parentRecordId Long>,<dataMap Map>,<connectionName String>,<userAccess Boolean>);
mandatory : module,recordID,parentModuleName,parentRecordId,dataMap

Sample Request:
resp = zoho.crm.updateRelatedRecord("Related_List_Name_2","7000000037119","Leads","7000000037002", Map());
CopiedZCRMRecord recordIns = ZCRMRecord.GetInstance("Leads", 337216400000); //module api name with record id
ZCRMJunctionRecord relatedRecord = ZCRMJunctionRecord.GetInstance("Campaigns", 33721640000001); //RelatedList api name with RelatedList record id
relatedRecord.SetRelatedDetails("Status", "active");
APIResponse response = recordIns.AddRelation(relatedRecord);
String recStatus = response.Status; //check status of the update relation
//In the above example, lead with ID 337216400000 gets associated with the campaign with ID 33721640000001.

Sample Response

Copied{
	"data":[
		{
			"id":"3652397000000327001",
			"Member_Status":"Active"
		
		},
		{
			"id":"3652397000001854001",
			"Member_Status":"Planning"
		
		}]
}
Copied{
    "data": [
        {
            "code": "SUCCESS",
            "details": {
                "id": "3652397000000327001"
            },
            "message": "relation added",
            "status": "success"
        },
        {
            "code": "SUCCESS",
            "details": {
                "id": "3652397000001854001"
            },
            "message": "relation added",
            "status": "success"
        }
    ]
}
Copiedcurl "https://www.zohoapis.com/crm/v2/Contacts/1000017063/Deals/1000013559"
-X PUT
-d @updaterelatedlead.json
-H "Authorization: Zoho-oauthtoken 1000.8cb99dxxxxxxxxxxxxx9be93.9b8xxxxxxxxxxxxxxxf"
Copied{
    "data": [
       {
            "Contact_Role": "1000000024229"
        }
    ]
}
Copiedcurl "https://www.zohoapis.com/crm/v2/Products/1000017063/Price_Books/1000013559"
-X PUT
-d @updaterelatedlead.json
-H "Authorization: Zoho-oauthtoken 1000.8cb99dxxxxxxxxxxxxx9be93.9b8xxxxxxxxxxxxxxxf"
Copied{
    "data": [
       {
            "list_price": 50.56
        }
    ]
}
Copied{
    "data": [
       {
            "code": "SUCCESS",
            "details": {
                "id": "4000000039247"
            },
            "message": "relation added",
            "status": "success"
        }
    ]
}
Copied{
    "data": [
       {
            "Member_Status": "active"
        }
    ]
}
CopiedZCRMRecord record = ZCRMRecord.getInstance("Products",880428000003772042l);//module api name with record id
ZCRMJunctionRecord relatedRecord = ZCRMJunctionRecord.getInstance("Price_Books", 880428000000261025l);
relatedRecord.setRelatedData("list_price", 50.56);
APIResponse response = record.addRelation(relatedRecord);
String recStatus = response.getStatus(); //check status of the update relation
Copied{
    "data": [
       {
            "list_price": 50.56
        }
    ]
}
Copied{
    "data": [
       {
            "code": "SUCCESS",
            "details": {
                "id": "4000000039247"
            },
            "message": "relation added",
            "status": "success"
        }
    ]
}
Copied{
    "data": [
       {
            "list_price": 50.56
        }
    ]
}
Copied{
    "data": [
       {
            "code": "SUCCESS",
            "details": {
                "id": "4000000039247"
            },
            "message": "relation added",
            "status": "success"
        }
    ]
}
Copied{
    "data": [
       {
            "Product_Name": MyProduct
        }
    ]
}
Copied{
    "data": [
       {
            "code": "SUCCESS",
            "details": {
                "id": "4000000039247"
            },
            "message": "relation added",
            "status": "success"
        }
    ]
}
Copied{
    "data": [
       {
            "code": "SUCCESS",
            "details": {
                "id": "4000000039247"
            },
            "message": "relation added",
            "status": "success"
        }
    ]
}
Copied{
    "data": [
       {
            "Member_Status": "active"
        }
    ]
}
Copied{
    "data": [
       {
            "code": "SUCCESS",
            "details": {
                "id": "4000000039247"
            },
            "message": "relation added",
            "status": "success"
        }
    ]
}

Sample Response

Copied{
	"data":[
		{
			"id":"3652397000000327001",
			"Member_Status":"Active"
		
		},
		{
			"id":"3652397000001854001",
			"Member_Status":"Planning"
		
		}]
}
Copied{
    "data": [
        {
            "code": "SUCCESS",
            "details": {
                "id": "3652397000000327001"
            },
            "message": "relation added",
            "status": "success"
        },
        {
            "code": "SUCCESS",
            "details": {
                "id": "3652397000001854001"
            },
            "message": "relation added",
            "status": "success"
        }
    ]
}
Copiedcurl "https://www.zohoapis.com/crm/v2/Contacts/1000017063/Deals/1000013559"
-X PUT
-d @updaterelatedlead.json
-H "Authorization: Zoho-oauthtoken 1000.8cb99dxxxxxxxxxxxxx9be93.9b8xxxxxxxxxxxxxxxf"
Copied{
    "data": [
       {
            "Contact_Role": "1000000024229"
        }
    ]
}
Copiedcurl "https://www.zohoapis.com/crm/v2/Products/1000017063/Price_Books/1000013559"
-X PUT
-d @updaterelatedlead.json
-H "Authorization: Zoho-oauthtoken 1000.8cb99dxxxxxxxxxxxxx9be93.9b8xxxxxxxxxxxxxxxf"
Copied{
    "data": [
       {
            "list_price": 50.56
        }
    ]
}
Copied{
    "data": [
       {
            "code": "SUCCESS",
            "details": {
                "id": "4000000039247"
            },
            "message": "relation added",
            "status": "success"
        }
    ]
}
Copied{
    "data": [
       {
            "Member_Status": "active"
        }
    ]
}
CopiedZCRMRecord record = ZCRMRecord.getInstance("Products",880428000003772042l);//module api name with record id
ZCRMJunctionRecord relatedRecord = ZCRMJunctionRecord.getInstance("Price_Books", 880428000000261025l);
relatedRecord.setRelatedData("list_price", 50.56);
APIResponse response = record.addRelation(relatedRecord);
String recStatus = response.getStatus(); //check status of the update relation
Copied{
    "data": [
       {
            "list_price": 50.56
        }
    ]
}
Copied{
    "data": [
       {
            "code": "SUCCESS",
            "details": {
                "id": "4000000039247"
            },
            "message": "relation added",
            "status": "success"
        }
    ]
}
Copied{
    "data": [
       {
            "list_price": 50.56
        }
    ]
}
Copied{
    "data": [
       {
            "code": "SUCCESS",
            "details": {
                "id": "4000000039247"
            },
            "message": "relation added",
            "status": "success"
        }
    ]
}
Copied{
    "data": [
       {
            "Product_Name": MyProduct
        }
    ]
}
Copied{
    "data": [
       {
            "code": "SUCCESS",
            "details": {
                "id": "4000000039247"
            },
            "message": "relation added",
            "status": "success"
        }
    ]
}
Copied{
    "data": [
       {
            "code": "SUCCESS",
            "details": {
                "id": "4000000039247"
            },
            "message": "relation added",
            "status": "success"
        }
    ]
}
Copied{
    "data": [
       {
            "Member_Status": "active"
        }
    ]
}
Copied{
    "data": [
       {
            "code": "SUCCESS",
            "details": {
                "id": "4000000039247"
            },
            "message": "relation added",
            "status": "success"
        }
    ]
}

Sample Response

Copied{
	"data":[
		{
			"id":"3652397000000327001",
			"Member_Status":"Active"
		
		},
		{
			"id":"3652397000001854001",
			"Member_Status":"Planning"
		
		}]
}
Copied{
    "data": [
        {
            "code": "SUCCESS",
            "details": {
                "id": "3652397000000327001"
            },
            "message": "relation added",
            "status": "success"
        },
        {
            "code": "SUCCESS",
            "details": {
                "id": "3652397000001854001"
            },
            "message": "relation added",
            "status": "success"
        }
    ]
}
Copiedcurl "https://www.zohoapis.com/crm/v2/Contacts/1000017063/Deals/1000013559"
-X PUT
-d @updaterelatedlead.json
-H "Authorization: Zoho-oauthtoken 1000.8cb99dxxxxxxxxxxxxx9be93.9b8xxxxxxxxxxxxxxxf"
Copied{
    "data": [
       {
            "Contact_Role": "1000000024229"
        }
    ]
}
Copiedcurl "https://www.zohoapis.com/crm/v2/Products/1000017063/Price_Books/1000013559"
-X PUT
-d @updaterelatedlead.json
-H "Authorization: Zoho-oauthtoken 1000.8cb99dxxxxxxxxxxxxx9be93.9b8xxxxxxxxxxxxxxxf"
Copied{
    "data": [
       {
            "list_price": 50.56
        }
    ]
}
Copied{
    "data": [
       {
            "code": "SUCCESS",
            "details": {
                "id": "4000000039247"
            },
            "message": "relation added",
            "status": "success"
        }
    ]
}
Copied{
    "data": [
       {
            "Member_Status": "active"
        }
    ]
}
CopiedZCRMRecord record = ZCRMRecord.getInstance("Products",880428000003772042l);//module api name with record id
ZCRMJunctionRecord relatedRecord = ZCRMJunctionRecord.getInstance("Price_Books", 880428000000261025l);
relatedRecord.setRelatedData("list_price", 50.56);
APIResponse response = record.addRelation(relatedRecord);
String recStatus = response.getStatus(); //check status of the update relation
Copied{
    "data": [
       {
            "list_price": 50.56
        }
    ]
}
Copied{
    "data": [
       {
            "code": "SUCCESS",
            "details": {
                "id": "4000000039247"
            },
            "message": "relation added",
            "status": "success"
        }
    ]
}
Copied{
    "data": [
       {
            "list_price": 50.56
        }
    ]
}
Copied{
    "data": [
       {
            "code": "SUCCESS",
            "details": {
                "id": "4000000039247"
            },
            "message": "relation added",
            "status": "success"
        }
    ]
}
Copied{
    "data": [
       {
            "Product_Name": MyProduct
        }
    ]
}
Copied{
    "data": [
       {
            "code": "SUCCESS",
            "details": {
                "id": "4000000039247"
            },
            "message": "relation added",
            "status": "success"
        }
    ]
}
Copied{
    "data": [
       {
            "code": "SUCCESS",
            "details": {
                "id": "4000000039247"
            },
            "message": "relation added",
            "status": "success"
        }
    ]
}
Copied{
    "data": [
       {
            "Member_Status": "active"
        }
    ]
}
Copied{
    "data": [
       {
            "code": "SUCCESS",
            "details": {
                "id": "4000000039247"
            },
            "message": "relation added",
            "status": "success"
        }
    ]
}

Sample Response

Copied{
	"data":[
		{
			"id":"3652397000000327001",
			"Member_Status":"Active"
		
		},
		{
			"id":"3652397000001854001",
			"Member_Status":"Planning"
		
		}]
}
Copied{
    "data": [
        {
            "code": "SUCCESS",
            "details": {
                "id": "3652397000000327001"
            },
            "message": "relation added",
            "status": "success"
        },
        {
            "code": "SUCCESS",
            "details": {
                "id": "3652397000001854001"
            },
            "message": "relation added",
            "status": "success"
        }
    ]
}
Copiedcurl "https://www.zohoapis.com/crm/v2/Contacts/1000017063/Deals/1000013559"
-X PUT
-d @updaterelatedlead.json
-H "Authorization: Zoho-oauthtoken 1000.8cb99dxxxxxxxxxxxxx9be93.9b8xxxxxxxxxxxxxxxf"
Copied{
    "data": [
       {
            "Contact_Role": "1000000024229"
        }
    ]
}
Copiedcurl "https://www.zohoapis.com/crm/v2/Products/1000017063/Price_Books/1000013559"
-X PUT
-d @updaterelatedlead.json
-H "Authorization: Zoho-oauthtoken 1000.8cb99dxxxxxxxxxxxxx9be93.9b8xxxxxxxxxxxxxxxf"
Copied{
    "data": [
       {
            "list_price": 50.56
        }
    ]
}
Copied{
    "data": [
       {
            "code": "SUCCESS",
            "details": {
                "id": "4000000039247"
            },
            "message": "relation added",
            "status": "success"
        }
    ]
}
Copied{
    "data": [
       {
            "Member_Status": "active"
        }
    ]
}
CopiedZCRMRecord record = ZCRMRecord.getInstance("Products",880428000003772042l);//module api name with record id
ZCRMJunctionRecord relatedRecord = ZCRMJunctionRecord.getInstance("Price_Books", 880428000000261025l);
relatedRecord.setRelatedData("list_price", 50.56);
APIResponse response = record.addRelation(relatedRecord);
String recStatus = response.getStatus(); //check status of the update relation
Copied{
    "data": [
       {
            "list_price": 50.56
        }
    ]
}
Copied{
    "data": [
       {
            "code": "SUCCESS",
            "details": {
                "id": "4000000039247"
            },
            "message": "relation added",
            "status": "success"
        }
    ]
}
Copied{
    "data": [
       {
            "list_price": 50.56
        }
    ]
}
Copied{
    "data": [
       {
            "code": "SUCCESS",
            "details": {
                "id": "4000000039247"
            },
            "message": "relation added",
            "status": "success"
        }
    ]
}
Copied{
    "data": [
       {
            "Product_Name": MyProduct
        }
    ]
}
Copied{
    "data": [
       {
            "code": "SUCCESS",
            "details": {
                "id": "4000000039247"
            },
            "message": "relation added",
            "status": "success"
        }
    ]
}
Copied{
    "data": [
       {
            "code": "SUCCESS",
            "details": {
                "id": "4000000039247"
            },
            "message": "relation added",
            "status": "success"
        }
    ]
}
Copied{
    "data": [
       {
            "Member_Status": "active"
        }
    ]
}
Copied{
    "data": [
       {
            "code": "SUCCESS",
            "details": {
                "id": "4000000039247"
            },
            "message": "relation added",
            "status": "success"
        }
    ]
}

Sample Response

Copied{
	"data":[
		{
			"id":"3652397000000327001",
			"Member_Status":"Active"
		
		},
		{
			"id":"3652397000001854001",
			"Member_Status":"Planning"
		
		}]
}
Copied{
    "data": [
        {
            "code": "SUCCESS",
            "details": {
                "id": "3652397000000327001"
            },
            "message": "relation added",
            "status": "success"
        },
        {
            "code": "SUCCESS",
            "details": {
                "id": "3652397000001854001"
            },
            "message": "relation added",
            "status": "success"
        }
    ]
}
Copiedcurl "https://www.zohoapis.com/crm/v2/Contacts/1000017063/Deals/1000013559"
-X PUT
-d @updaterelatedlead.json
-H "Authorization: Zoho-oauthtoken 1000.8cb99dxxxxxxxxxxxxx9be93.9b8xxxxxxxxxxxxxxxf"
Copied{
    "data": [
       {
            "Contact_Role": "1000000024229"
        }
    ]
}
Copiedcurl "https://www.zohoapis.com/crm/v2/Products/1000017063/Price_Books/1000013559"
-X PUT
-d @updaterelatedlead.json
-H "Authorization: Zoho-oauthtoken 1000.8cb99dxxxxxxxxxxxxx9be93.9b8xxxxxxxxxxxxxxxf"
Copied{
    "data": [
       {
            "list_price": 50.56
        }
    ]
}
Copied{
    "data": [
       {
            "code": "SUCCESS",
            "details": {
                "id": "4000000039247"
            },
            "message": "relation added",
            "status": "success"
        }
    ]
}
Copied{
    "data": [
       {
            "Member_Status": "active"
        }
    ]
}
CopiedZCRMRecord record = ZCRMRecord.getInstance("Products",880428000003772042l);//module api name with record id
ZCRMJunctionRecord relatedRecord = ZCRMJunctionRecord.getInstance("Price_Books", 880428000000261025l);
relatedRecord.setRelatedData("list_price", 50.56);
APIResponse response = record.addRelation(relatedRecord);
String recStatus = response.getStatus(); //check status of the update relation
Copied{
    "data": [
       {
            "list_price": 50.56
        }
    ]
}
Copied{
    "data": [
       {
            "code": "SUCCESS",
            "details": {
                "id": "4000000039247"
            },
            "message": "relation added",
            "status": "success"
        }
    ]
}
Copied{
    "data": [
       {
            "list_price": 50.56
        }
    ]
}
Copied{
    "data": [
       {
            "code": "SUCCESS",
            "details": {
                "id": "4000000039247"
            },
            "message": "relation added",
            "status": "success"
        }
    ]
}
Copied{
    "data": [
       {
            "Product_Name": MyProduct
        }
    ]
}
Copied{
    "data": [
       {
            "code": "SUCCESS",
            "details": {
                "id": "4000000039247"
            },
            "message": "relation added",
            "status": "success"
        }
    ]
}
Copied{
    "data": [
       {
            "code": "SUCCESS",
            "details": {
                "id": "4000000039247"
            },
            "message": "relation added",
            "status": "success"
        }
    ]
}
Copied{
    "data": [
       {
            "Member_Status": "active"
        }
    ]
}
Copied{
    "data": [
       {
            "code": "SUCCESS",
            "details": {
                "id": "4000000039247"
            },
            "message": "relation added",
            "status": "success"
        }
    ]
}