Details
-
Type: Bug
-
Status: Done/Fixed
-
Priority: Major
-
Resolution: Fixed/Completed
-
Affects Version/s: 4.3.7
-
Fix Version/s: 4.4.1
-
Component/s: CiviCRM API
-
Labels:
Description
The _civicrm_api_call_nested_api() function is currently broken if you want to add multiple object to the same entity by chaining them. This is because the $entity variable gets overwritten (line 478).
The attached 'patch' solves the problem (the $entity key isn't used, so not necessary)
Code that fails without the patch (throws Mandatory key(s) missing from params array: contact_id) :
$contact_array = array(
'contact_type' => 'Individual',
'first_name' => 'Test',
'last_name' => 'User',
'api.email.create' => array(
0 => array(
'email' => 'test_email@example.com',
),
),
'api.address.create' => array(
0 => array(
'street_address' => 'the adress 10',
'postal_code' => '1234',
'city' => 'City',
'country_id' => 1020,
'location_type_id' => 1,
)
),
'version' => 3,
);
$result = civicrm_api("Contact", "Create", $contact_array);