Skip to content

Commit

Permalink
Merge pull request #13188 from JMAConsulting/core-563
Browse files Browse the repository at this point in the history
dev/core#563: Duplicate Case manager role fix
  • Loading branch information
seamuslee001 authored Dec 5, 2018
2 parents 1a5a38d + a0fdfb6 commit be10788
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions CRM/Contact/Page/AJAX.php
Original file line number Diff line number Diff line change
Expand Up @@ -247,13 +247,22 @@ public static function relationship() {
// Loop through multiple case clients
foreach ($clientList as $i => $sourceContactID) {
try {
$result = civicrm_api3('relationship', 'create', array(
$params = [
'case_id' => $caseID,
'relationship_type_id' => $relTypeId,
"contact_id_$a" => $relContactID,
"contact_id_$b" => $sourceContactID,
'sequential' => TRUE,
];
// first check if there is any existing relationship present with same parameters.
// If yes then update the relationship by setting active and start date to current time
$relationship = civicrm_api3('Relationship', 'get', $params)['values'];
$params = array_merge(CRM_Utils_Array::value(0, $relationship, $params), [
'start_date' => 'now',
));
'is_active' => TRUE,
'end_date' => '',
]);
$result = civicrm_api3('relationship', 'create', $params);
}
catch (CiviCRM_API3_Exception $e) {
$ret['is_error'] = 1;
Expand Down

0 comments on commit be10788

Please sign in to comment.