set_relationship
Overview
Sets relationships between two records. You can relate multiple records to a single record using this.
Available APIs
Definition
set_relationship(session, module_name, module_id, link_field_name, related_ids, name_value_list, delete)
Parameters
Name |
Type |
Description |
session |
String |
Session ID returned by a previous login call. |
module_name |
String |
The name of the module from which to retrieve records. Note: This is the modules key which may not be the same as the modules display name. |
module_id |
String |
The ID of the specified module record. |
link_field_name |
String |
The name of the link field for the related module. |
related_ids |
select_fields | Array |
The list of related record IDs you are relating |
name_value_list |
name_value_list | Array |
An array specifying relationship fields to populate. An example of this is contact_role between Opportunities and Contacts. |
delete |
Integer |
Determines whether the relationship is being created or deleted. 0:create, 1:delete |
Result
Name |
Type |
Description |
result |
new_set_relationship_list_result | Array |
The call result |
result.created |
Integer |
The number of relationships created. |
result.failed |
Integer |
Determines whether or not the relationship failed. This is normally thrown when the parameters module_name or link_field_name are incorrect. |
result.deleted |
Integer |
The number of relationships deleted. |
Change Log
Version |
Change |
v2 |
Removed set_relationship_value parameter. |
v2 |
Added module_name parameter. |
v2 |
Added module_id parameter. |
v2 |
Added link_field_name parameter. |
v2 |
Added related_ids parameter. |
v2 |
Added name_value_list parameter. |
v2 |
Added delete parameter. |
v2 |
Return type was changed from error_value to new_set_relationship_list_result. |
Examples
PHP
$set_relationship_parameters = array(
//session id
'session' => $session_id,
//The name of the module.
'module_name' => 'Opportunities',
//The ID of the specified module bean.
'module_id' => '15e79b92-5025-827f-0784-50aa578270d8',
//The relationship name of the linked field from which to relate records.
'link_field_name' => 'contacts',
//The list of record ids to relate
'related_ids' => array(
'19b8799e-64ae-9502-588c-50aa575454c9',
),
//Sets the value for relationship based fields
'name_value_list' => array(
array(
'name' => 'contact_role',
'value' => 'Other'
)
),
//Whether or not to delete the relationship. 0:create, 1:delete
'delete'=> 0,
);