Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dev/core#563: Duplicate Case manager role fix #13188

Merged
merged 1 commit into from
Dec 5, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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