Details
-
Type: Bug
-
Status: Done/Fixed
-
Priority: Major
-
Resolution: Fixed/Completed
-
Affects Version/s: 3.2.3
-
Fix Version/s: 3.2.4
-
Component/s: CiviCRM API
-
Labels:None
Description
When using civicrm_location_update(), switching the e-mail to a different location gives the following error:
"Invalid Location Type(s) : Work"
where 'Work' is the location_type_id assigned. Same error for Main, Other, Billing, etc.
$params = array(
'first_name' => 'Joe',
'last_name' => 'Blow',
'email' => 'joeblow@example.org',
'contact_type' => 'Individual'
);
require_once 'api/v2/Contact.php';
$contact = civicrm_contact_add($params);
$id = $contact['contact_id'];
$params = civicrm_location_get(array('contact_id' => $id, 'version' => '3.0'));
$params['contact_id'] = $id;
$params['version'] = '3.0';
// switch from home to work
$params['email']['1']['location_type_id'] = 2;
$result =& civicrm_location_update($params);
print_r($result);
The result is:
Array
(
[is_error] => 1
[error_message] => Invalid Location Type(s) : Work
)
This presents a problem when adding an organization via the API using civicrm_contact_add() since the default location for an e-mail address is 'Home.'